-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 8 commits
c17672a
48e86a8
cf13d0b
082df98
823656c
b46b772
9820d8c
b424a4e
f2528b6
55796d7
e0d7bcd
3dfa9f8
24a4f52
dcdb8a8
de869cd
6aead2a
734bce6
5bedeff
193a419
90054fc
4af22b2
229ee0a
941d47e
3fa3564
76aed83
f5365fb
8678285
d391a66
32814c7
4ade1db
7f3882a
c218122
96f7975
eb3bd84
9af955c
7972cef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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 | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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: | ||
|
@@ -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 { | ||
|
There was a problem hiding this comment.
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 outbidder['available_bidder_details']['oc_bureau']
on line 59 again (also happens twice on line 60 and once on line 61).There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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