in osci/notify/generate_email/generate_email.py [0:0]
def generate_email_body(date: datetime, company=Config().default_company):
report = OSCIChangeRanking(date=date)
company_contributors_ranking_schema = DataLake().public.schemas.company_contributors_ranking
change_ranking = report.read().reset_index()
change_ranking = change_ranking.rename(columns={'index': company_contributors_ranking_schema.position})
change_ranking[company_contributors_ranking_schema.position] += 1
change_ranking = __cast_columns_to_int(df=change_ranking,
columns=[
report.schema.total,
report.schema.active,
company_contributors_ranking_schema.position,
report.schema.total_change,
report.schema.active_change,
report.schema.position_change,
])
shift_up = __add_arrows_prefix(df=__get_shift_up(change_ranking=change_ranking,
change_position_field=report.schema.position_change),
column=report.schema.position_change)
shift_down = __add_arrows_prefix(df=__get_shift_down(change_ranking=change_ranking,
change_position_field=report.schema.position_change),
column=report.schema.position_change)
company_position = __add_arrows_prefix(df=__get_company_neighbors(df=change_ranking,
company=company,
company_field=report.schema.company,
rank_field=company_contributors_ranking_schema.position),
column=report.schema.position_change)
DataLake().public.save_email(email_body=EmailBodyTemplate().render(
date=date,
compared_date=get_previous_date(date),
shift_up=shift_up,
shift_down=shift_down,
company=company,
company_position=company_position,
solutionshub_osci_change_ranking=OSCIChangeRankingExcel(to_date=date).url,
osci_reports_urls={name: report_cls(date=date).url for name, report_cls in OSCI_REPORTS_URLS.items()}
), date=date)