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

updating ab chart stats TM-2409 #654

Merged
merged 36 commits into from
Jan 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c17672a
updating ab chart stats
SidelineCory24 Jan 6, 2022
48e86a8
Merge branch 'dev' into update/available-bidders-chart-stats
SidelineCory24 Jan 6, 2022
cf13d0b
sorting grade & skill
SidelineCory24 Jan 8, 2022
082df98
adding OC Bureau to data structure
SidelineCory24 Jan 11, 2022
823656c
Merge branch 'dev' into update/available-bidders-chart-stats
SidelineCory24 Jan 11, 2022
b46b772
Update available_bidders.py
SidelineCory24 Jan 11, 2022
9820d8c
updating comments
SidelineCory24 Jan 11, 2022
b424a4e
Merge branch 'update/available-bidders-chart-stats' of github.com:Met…
SidelineCory24 Jan 11, 2022
f2528b6
updating filter code
SidelineCory24 Jan 11, 2022
55796d7
cleaning up test
SidelineCory24 Jan 11, 2022
e0d7bcd
variable naming updates
SidelineCory24 Jan 11, 2022
3dfa9f8
code simplification
SidelineCory24 Jan 12, 2022
24a4f52
adding comment for 2+ post filtering
SidelineCory24 Jan 12, 2022
dcdb8a8
adding None data point into chart
SidelineCory24 Jan 13, 2022
de869cd
updating variable naming
SidelineCory24 Jan 13, 2022
6aead2a
updating data structure when stat returns None
SidelineCory24 Jan 13, 2022
734bce6
Merge branch 'dev' into update/available-bidders-chart-stats
SidelineCory24 Jan 14, 2022
5bedeff
updating CDO None value to None listed
SidelineCory24 Jan 14, 2022
193a419
Merge branch 'dev' into update/available-bidders-chart-stats
SidelineCory24 Jan 14, 2022
90054fc
handling edge case of showing no posts at all
SidelineCory24 Jan 14, 2022
4af22b2
Merge branch 'update/available-bidders-chart-stats' of github.com:Met…
SidelineCory24 Jan 14, 2022
229ee0a
Update available_bidders.py
SidelineCory24 Jan 14, 2022
941d47e
post not posts
SidelineCory24 Jan 14, 2022
3fa3564
updating variables
SidelineCory24 Jan 18, 2022
76aed83
updating none listed variable
SidelineCory24 Jan 18, 2022
f5365fb
removing instanceOf check
SidelineCory24 Jan 18, 2022
8678285
code simplification
SidelineCory24 Jan 18, 2022
d391a66
fixing none listed sum bug
SidelineCory24 Jan 18, 2022
32814c7
Merge branch 'dev' into update/available-bidders-chart-stats
SidelineCory24 Jan 18, 2022
4ade1db
removing grade text
SidelineCory24 Jan 18, 2022
7f3882a
Merge branch 'update/available-bidders-chart-stats' of github.com:Met…
SidelineCory24 Jan 18, 2022
c218122
simplifying stat creation
SidelineCory24 Jan 19, 2022
96f7975
updating variable naming
SidelineCory24 Jan 19, 2022
eb3bd84
adding skill to stat creation function
SidelineCory24 Jan 20, 2022
9af955c
simplfying skill stat
SidelineCory24 Jan 20, 2022
7972cef
Merge branch 'dev' into update/available-bidders-chart-stats
mjoyce91 Jan 20, 2022
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
27 changes: 14 additions & 13 deletions talentmap_api/cdo/services/available_bidders.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_available_bidders_stats(data):
{ 'key': 'grade', 'statsKey': 'Grade' },
{ 'key': 'available_bidder_details.oc_bureau', 'statsKey': 'OC Bureau' },
{ 'key': 'pos_location', 'statsKey': 'Post' },
{ 'key': 'skills', 'statsKey': 'Skill' },
{ 'key': 'available_bidder_details.status', 'statsKey': 'Status' },
]

Expand All @@ -61,22 +62,22 @@ def get_available_bidders_stats(data):
# get stats for various fields
for bidder in pydash.get(data, 'results'):
def map_object(stat):
key = pydash.get(bidder, stat['key'])
if key not in stats[stat['statsKey']]:
stats[stat['statsKey']][key] = deepcopy(none_listed) if key == None else {'name': f"{key}", 'value': 0}
stats[stat['statsKey']][key]['value'] += 1
stats_sum[stat['statsKey']] += 1
if stat['key'] == 'skills':
skill = list(deepcopy(filter(None, bidder[stat['key']])))
skill_key = skill[0]['code']
if skill_key not in stats['Skill']:
stats['Skill'][skill_key] = deepcopy(none_listed) if skill_key == None else {'name': f"{skill[0]['description']}", 'value': 0}
stats['Skill'][skill_key]['value'] += 1
stats_sum[stat['statsKey']] += 1
else:
key = pydash.get(bidder, stat['key'])
if key not in stats[stat['statsKey']]:
stats[stat['statsKey']][key] = deepcopy(none_listed) if key == None else {'name': f"{key}", 'value': 0}
stats[stat['statsKey']][key]['value'] += 1
stats_sum[stat['statsKey']] += 1
Copy link

@mjoyce91 mjoyce91 Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're still duplicating a lot of the same code. For example, we always run stats_sum[stat['statsKey']] += 1 regardless of which path the if/else takes, so why have that in both blocks?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplified skill code has been pushed


pydash.for_each(config, map_object)

# need to add skill in map_object func
skill = list(deepcopy(filter(None, bidder['skills'])))
skill_key = skill[0]['code']
if skill_key not in stats['Skill']:
stats['Skill'][skill_key] = deepcopy(none_listed) if skill_key == None else {'name': f"{skill[0]['description']}", 'value': 0}
stats['Skill'][skill_key]['value'] += 1
stats_sum['Skill'] += 1

# adding percentage & creating final data structure to pass to FE
bidders_stats = {}
for stat in stats:
Expand Down