-
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
Conversation
Note: only showing Post with 2+ AB was added to the |
comment update
…aPhase-Consulting/State-TalentMap-API into update/available-bidders-chart-stats
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 |
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 out bidder['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:
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
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
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 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
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.
done
if len(biddersStats['Post']) > 18: | ||
biddersStats['Post'] = filter(lambda post: post['value'] > 1, biddersStats['Post']) | ||
|
||
biddersStats['Grade'] = sorted(biddersStats['Grade'], key = lambda grade: grade['name']) |
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.
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.
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.
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.
Yes let's include all make sure they match
…aPhase-Consulting/State-TalentMap-API into update/available-bidders-chart-stats
comment update
See this comment, as it's probably more API related - MetaPhase-Consulting/State-TalentMAP#1909 (comment) |
bureau_key = pydash.get(bidder, 'current_assignment.position.bureau_code') | ||
if bureau_key not in stats['Bureau']: | ||
no_bureau = none_listed | ||
bureau = {'name': f"{bureau_key}", 'value': 0} | ||
stats['Bureau'][bureau_key] = no_bureau if bureau_key == None else bureau | ||
stats['Bureau'][bureau_key]['value'] += 1 | ||
stats_sum['Bureau'] += 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 | ||
cdo_full_name_key = pydash.get(bidder, 'cdo.full_name') | ||
if cdo_full_name_key not in stats['CDO']: | ||
no_cdo = none_listed | ||
cdo = {'name': f"{cdo_full_name_key}", 'value': 0} | ||
stats['CDO'][cdo_full_name_key] = no_cdo if cdo_full_name_key == None else cdo | ||
stats['CDO'][cdo_full_name_key]['value'] += 1 | ||
stats_sum['CDO'] += 1 | ||
|
||
grade_key = pydash.get(bidder, 'grade') | ||
if grade_key not in stats['Grade']: | ||
no_grade = none_listed | ||
grade = {'name': f"Grade {grade_key}", 'value': 0} | ||
stats['Grade'][grade_key] = no_grade if grade_key == None else grade | ||
stats['Grade'][grade_key]['value'] += 1 | ||
stats_sum['Grade'] += 1 | ||
|
||
if bidder['pos_location'] not in stats['Post']: | ||
stats['Post'][bidder['pos_location']] = {'name': f"{bidder['pos_location']}", 'value': 0} | ||
stats['Post'][bidder['pos_location']]['value'] += 1 | ||
oc_bureau_key = pydash.get(bidder, 'available_bidder_details.oc_bureau') | ||
if oc_bureau_key not in stats['OC Bureau']: | ||
no_oc_bureau = none_listed | ||
oc_bureau = {'name': f"{oc_bureau_key}", 'value': 0} | ||
stats['OC Bureau'][oc_bureau_key] = no_oc_bureau if oc_bureau_key == None else oc_bureau | ||
stats['OC Bureau'][oc_bureau_key]['value'] += 1 | ||
stats_sum['OC Bureau'] += 1 | ||
|
||
post_key = pydash.get(bidder, 'pos_location') | ||
if post_key not in stats['Post']: | ||
no_post = none_listed | ||
post = {'name': f"{post_key}", 'value': 0} | ||
stats['Post'][post_key] = no_post if post_key == None else post | ||
stats['Post'][post_key]['value'] += 1 | ||
stats_sum['Post'] += 1 | ||
|
||
skill = list(deepcopy(filter(None, bidder['skills']))) | ||
skill_key = skill[0]['code'] | ||
if skill_key not in stats['Skill']: | ||
stats['Skill'][skill_key] = {'name': f"{skill[0]['description']}", 'value': 0} | ||
no_skill = none_listed | ||
skill = {'name': f"{skill[0]['description']}", 'value': 0} | ||
stats['Skill'][skill_key] = no_skill if skill_key == None else skill | ||
stats['Skill'][skill_key]['value'] += 1 | ||
stats_sum['Skill'] += 1 | ||
|
||
ab_status_key = pydash.get(bidder, 'available_bidder_details.status') | ||
if ab_status_key: | ||
if ab_status_key not in stats['Status']: | ||
stats['Status'][ab_status_key] = {'name': f"{ab_status_key}", 'value': 0} | ||
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 | ||
status_key = pydash.get(bidder, 'available_bidder_details.status') | ||
if status_key not in stats['Status']: | ||
no_status = none_listed | ||
status = {'name': f"{status_key}", 'value': 0} | ||
stats['Status'][status_key] = no_status if status_key == None else status | ||
stats['Status'][status_key]['value'] += 1 | ||
stats_sum['Status'] += 1 |
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.
All of these blocks of code are doing basically the same thing. What if we abstracted away the differences to a config object to make this more DRY?
config = [
{ 'key': 'current_assignment.position.bureau_code', 'statsKey': 'Bureau' },
...
]
def map_object(x):
key = pydash.get(bidder, x['key'])
if key not in stats[x['statsKey']]:
fallback_text = none_listed
obj = {'name': f"{key}", 'value': 0}
stats[(x['statsKey'])[key] = fallback_text if key == None else obj
stats[x['statsKey']][key]['value'] += 1
stats_sum[x['statsKey']] += 1
pydash.for_each(config, map_object)
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.
Had to make a few edits, also this is not tested
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.
done, except for handling the skill
Looks like this is causing the improper adding, @mjoyce91 @elizabeth-jimenez would this make more sense Mike I saw your comment about the config/function to do all of this code as well |
…aPhase-Consulting/State-TalentMap-API into update/available-bidders-chart-stats
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 |
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.
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?
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.
simplified skill code has been pushed
FE PR
To-Do:
Status
optionNote: Product Owner okay'd adding the OC Bureau dropdown and keeping the Bureau dropdown as well (current assignment)