Skip to content

Commit

Permalink
Merge pull request #57 from ElemarJR/people_appointments
Browse files Browse the repository at this point in the history
People appointments
  • Loading branch information
ElemarJR authored Dec 4, 2024
2 parents c20cf7e + 410ab34 commit 261d941
Show file tree
Hide file tree
Showing 10 changed files with 1,170 additions and 120 deletions.
39 changes: 39 additions & 0 deletions backend/src/api/datasets/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,48 @@ type TimesheetSummary implements ISummary {
byWeek: [WeekSummary!]!
byOffer: [NamedSummary!]!

appointments: [Appointment!]!

filterableFields: [FilterableField]!
}

type Appointment {
createdAt: Date!
date: Date!
comment: String

dayOfWeek: String!
month: String!
year: String!
yearMonth: String!

isSquad: Boolean!
isEximiaco: Boolean!

week: String!

timeInHs: Float!

kind: String!
createdAtWeek: String!

correctness: String!
isLte: Boolean!

workerName: String!
workerSlug: String!

caseTitle: String!

sponsor: String!
clientName: String!

accountManagerName: String!
accountManagerSlug: String!

productsOrServices: String!
}

type KindSummary {
internal: OneKindSummary
consulting: OneKindSummary
Expand Down
30 changes: 30 additions & 0 deletions backend/src/api/datasets/timesheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from graphql import GraphQLResolveInfo

from api.utils.fields import build_fields_map, get_requested_fields_from, get_selections_from_info
from models.helpers.slug import slugify

import globals

Expand Down Expand Up @@ -281,6 +282,35 @@ def compute_timesheet(map, slug: str=None, kind: str="ALL", filters = None):

if 'byOffer' in requested_fields:
result['by_offer'] = summarize_by_offer(df, map['byOffer'])

if 'appointments' in requested_fields:
def summarize_appointments(df, fields):
appointments = []

fields_slugs = {}
for field in fields:
# Convert camelCase to snake_case
parts = []
current_part = field[0].lower()
for c in field[1:]:
if c.isupper():
parts.append(current_part)
current_part = c.lower()
else:
current_part += c
parts.append(current_part)
field_slug = '_'.join(parts)
fields_slugs[field] = field_slug

for _, row in df.iterrows():
appointment = {}
for field in fields:
field_slug = fields_slugs[field]
appointment[field_slug] = row[field]
appointments.append(appointment)
return appointments

result['appointments'] = summarize_appointments(df, globals.omni_datasets.timesheets.get_all_fields())

return result

Expand Down
1 change: 1 addition & 0 deletions backend/src/models/datasets/timesheet_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def get_all_fields(self):
'DayOfWeek',
'Month',
'Year',
'Comment',
'YearMonth',
'UserId',
'Time',
Expand Down
Loading

0 comments on commit 261d941

Please sign in to comment.