Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DGJ Added no of positions field in employee data API #1704

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion forms-flow-api/src/formsflow_api/models/employee_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class EmployeeData():
# data: Response retrieved from the ODS
# Spec of possible values can be found at: https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rst#Datamart_Telework_employee_demo
def __init__(self, data, noofrecords=1):
def __init__(self, data, noofrecords=1, noofpositions=1):
self.displayName = " ".join(filter(None, (data.get("first_name"), data.get("last_name"))))
self.name = data.get("name")
self.firstName = data.get("first_name")
Expand Down Expand Up @@ -67,3 +67,4 @@ def __init__(self, data, noofrecords=1):
# Possible values: "P" for Primary, "S" for Secondary and "N" for Not Applicable
self.jobIndicator = data.get("job_indicator")
self.noofrecords = noofrecords
self.noofpositions = noofpositions
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def get_employee_data_from_bcgov(guid):
employee_data_res = response_from_BCGov.json()

if employee_data_res and employee_data_res["value"] and len(employee_data_res["value"]) > 0:
emp_data = EmployeeData(employee_data_res["value"][0], len(employee_data_res["value"]))
noofrecords = len(employee_data_res["value"])
if len(employee_data_res["value"]) > 1:
positions = set(job['position_number'] for job in employee_data_res["value"])
emp_data = EmployeeData(employee_data_res["value"][0], noofrecords, len(positions))
else:
emp_data = EmployeeData(employee_data_res["value"][0], noofrecords, 1)
cache.set(guid, emp_data, timeout=14400)
return emp_data.__dict__
else:
Expand Down
Loading