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 8 commits
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
37 changes: 27 additions & 10 deletions talentmap_api/cdo/services/available_bidders.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ def get_available_bidders_stats(data):
'''
stats = {
'Bureau': {}, # comes through, but only with the short name/acronym
'CDO': {},
'Grade': {},
'OC Bureau': {},
'Post': {},
'Skill': {},
'Status': {},
'TED': {},
}
stats_sum = {
'Bureau': 0,
'CDO': 0,
'Grade': 0,
'OC Bureau': 0,
'Post': 0,
'Skill': 0,
'Status': 0,
'TED': 0,
}

if data:
Expand All @@ -50,7 +52,20 @@ def get_available_bidders_stats(data):
stats['Bureau'][bidder['current_assignment']['position']['bureau_code']] = {'name': f"{bidder['current_assignment']['position']['bureau_code']}", 'value': 0}
stats['Bureau'][bidder['current_assignment']['position']['bureau_code']]['value'] += 1
stats_sum['Bureau'] += 1


# may need to remove, will follow up with product owners
ab_oc_bureau_key = pydash.get(bidder, 'available_bidder_details.oc_bureau')
if ab_oc_bureau_key:
if bidder['available_bidder_details']['oc_bureau'] not in stats['OC Bureau']:
stats['OC Bureau'][bidder['available_bidder_details']['oc_bureau']] = {'name': f"{bidder['available_bidder_details']['oc_bureau']}", 'value': 0}
stats['OC Bureau'][bidder['available_bidder_details']['oc_bureau']]['value'] += 1

Choose a reason for hiding this comment

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

Since you already defined ab_oc_bureau_key on line 57, you may as well just use that instead of calling out bidder['available_bidder_details']['oc_bureau'] on line 59 again (also happens twice on line 60 and once on line 61).

Copy link
Author

Choose a reason for hiding this comment

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

getting this error when trying to make the update, this is the code:

ab_oc_bureau_key = pydash.get(bidder, 'available_bidder_details.oc_bureau')
            if ab_oc_bureau_key:
                if bidder[ab_oc_bureau_key] not in stats['OC Bureau']:
                    stats['OC Bureau'][bidder[ab_oc_bureau_key]] = {'name': f"{bidder[ab_oc_bureau_key]}", 'value': 0}
                stats['OC Bureau'][bidder[ab_oc_bureau_key]]['value'] += 1
                stats_sum['OC Bureau'] += 1

image

Copy link
Author

@SidelineCory24 SidelineCory24 Jan 12, 2022

Choose a reason for hiding this comment

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

disregard, I can't copy/paste, the fix has been pushed

stats_sum['OC Bureau'] += 1

if bidder['cdo']['full_name'] not in stats['CDO']:
stats['CDO'][bidder['cdo']['full_name']] = {'name': f"CDO {bidder['cdo']['full_name']}", 'value': 0}
stats['CDO'][bidder['cdo']['full_name']]['value'] += 1

Choose a reason for hiding this comment

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

Similar idea with full_name. Let's just set a variable to reference the fullname like bidderFullName = pydash.get(bidder, 'cdo.full_name') and then reference that

Copy link
Author

Choose a reason for hiding this comment

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

done

stats_sum['CDO'] += 1

if bidder['grade'] not in stats['Grade']:
stats['Grade'][bidder['grade']] = {'name': f"Grade {bidder['grade']}", 'value': 0}
stats['Grade'][bidder['grade']]['value'] += 1
Expand All @@ -75,13 +90,6 @@ def get_available_bidders_stats(data):
stats['Status'][ab_status_key]['value'] += 1
stats_sum['Status'] += 1

ted_key = ensure_date(pydash.get(bidder, "current_assignment.end_date"), utc_offset=-5) or 'None listed'
ted_key = "None listed" if ted_key is "None listed" else smart_str(maya.parse(ted_key).datetime().strftime('%m/%d/%Y'))
if ted_key not in stats['TED']:
stats['TED'][ted_key] = {'name': f"{ted_key}", 'value': 0}
stats['TED'][ted_key]['value'] += 1
stats_sum['TED'] += 1

# adding percentage & creating final data structure to pass to FE
biddersStats = {}
for stat in stats:
Expand All @@ -91,6 +99,15 @@ def get_available_bidders_stats(data):
stat_value = stats[stat][s]['value']
biddersStats[stat].append({**stats[stat][s], 'percent': "{:.0%}".format(stat_value / stat_sum)})

if len(biddersStats['Post']) > 18:
multiplePost = []
for post in biddersStats['Post']:
if post['value'] > 1:
multiplePost.append(post)
biddersStats['Post'] = multiplePost
elizabeth-jimenez marked this conversation as resolved.
Show resolved Hide resolved
elizabeth-jimenez marked this conversation as resolved.
Show resolved Hide resolved

biddersStats['Grade'] = sorted(biddersStats['Grade'], key = lambda bidder: bidder['name'])
biddersStats['Skill'] = sorted(biddersStats['Skill'], key = lambda bidder: bidder['name'])
elizabeth-jimenez marked this conversation as resolved.
Show resolved Hide resolved
biddersStats['Sum'] = stats_sum

return {
Expand Down