← Reports

SafairBru Rewrite Gap Analysis

Old: app.py (monolithic) → New: domain/ + routers/ (modular)

205
Old Functions
202
New Functions
33
Exact Match
70
Renamed
44
Missing Core
3
Missing Export
25
Skipped (UI/Debug)
Migration Coverage (excl. UI-specific & debug infra) 57.2%
57.2%

Missing Core Logic — Must Be Migrated

SectionFunctionLineSize
AI Commentaryget_ai_roast(username, stats)L147283L
AI Commentarygenerate_roast_for_user(username, stats)L15646L
AI Commentaryget_ai_performance_analysis(username, profile_stats, all_time_lb...)L1572119L
AI Commentarygenerate_performance_analysis(username, profile_stats, all_time_lb...)L169320L
AI Commentaryget_month_events_tips(db, month_str)L1966108L
AI Integration_clamp_int(value, low, high)L3337L
AI Integration_tone_level(value)L34211L
AI Integrationresolve_tone_config(settings)L35541L
AI Integrationget_openai_client_class()L4345L
AI Integrationget_plotly_go()L4425L
AI Integrationget_competition_ai_guardrails()L54111L
AI Integrationis_ai_error_response(text)L5545L
AI Live Commentaryget_forecast_submission_commentary(db, username, month_str...)L255366L
Auth & Passwordsend_firebase_password_reset_email(email, db)L525824L
Auth & Passwordverify_firebase_email_password(email, password, db)L528414L
Auth & Passwordensure_firebase_auth_user(email, display_name)L530033L
Auth & Passwordfirebase_auth_user_exists(email)L533517L
Auth & Passwordget_firebase_auth_email_set()L535418L
Auth & Passwordshould_store_local_password_hash(db)L53747L
Auth & Passwordsync_password_to_firebase_auth(email, password, display_name)L538322L
Auth & Passwordrequest_password_reset_for_user(db, username, user_data...)L542559L
Cachingsave_local_data(data)L366910L
Cachingset_cached_data(cache_key, data, ttl_seconds)L37077L
Cachingclear_leaderboard_related_caches()L373110L
Cachingclear_forecast_related_caches()L37434L
Email Systemget_firebase_web_api_key(db)L383511L
Email System_next_month_str(month_str)L405211L
Email System_build_metric_rows_for_results(scores, actuals, metric_type)L4074115L
Email System_build_forecast_rows_for_metric(forecasts_map, metric_type)L419135L
Email Systembuild_forecast_lock_email_content(db, month, month_label...)L4228162L
Email Systemget_metric_results_email_commentary(db, month, metric_name...)L439237L
Email Systembuild_results_published_email_content(db, month, month_label...)L4431262L
Email Systemcreate_event_email_log(db, entry)L483114L
Email Systemmark_event_email_log_retried(db, log_id, retry_by...)L491222L
Email Systemretry_event_email_from_log(db, log_id, retry_by)L493624L
Firebase Initget_local_data()L365116L
Forecasts & Scoringget_actuals_for_scoring(db, month, monthly_df)L642522L
Forecasts & Scoring_fetch_dropbox_data_internal()L645477L
Leaderboard Stateofficial_pts(s)L20949L
Leaderboard Stateget_previous_leaderboard_state(db, metric_type, month_str)L219813L
Leaderboard Stateget_movement_indicator(username, current_rank, prev_state...)L224231L
Login Tokenshash_token(token)L56233L
Login Tokenssave_login_token(db, username, token...)L562815L
User Managementis_email_in_use(db, email, exclude_username)L378325L

Missing Export Features

FunctionLineSize
df_to_imageL629104L
plotly_to_imageL7359L
generate_whatsapp_textL107330L

Likely Renames (verify)

Old NameNew NameMatchNew File
init_firebase_init_firebase100%domain/firebase.py
normalize_email_normalize_email100%domain/email.py
is_valid_email_is_valid_email100%domain/email.py
get_sast_now_get_sast_now100%domain/scheduler.py
send_app_event_email_send_app_event_email100%domain/email.py
get_first_workday_of_month_get_first_workday_of_month100%domain/scheduler.py
build_ai_tone_directivebuild_tone_directive93%domain/ai.py
get_month_end_commentarygenerate_month_end_commentary91%domain/ai.py
get_rivals_commentarygenerate_rivals_commentary89%domain/ai.py
get_leaderboard_mode_flagsget_leaderboard_flags89%domain/settings.py
send_winners_announcement_emailsend_winners_announcement89%domain/email.py
_get_current_usernameget_current_user89%routers/pages.py
get_ai_settingsget_settings89%domain/settings.py
count_recent_bulk_event_sends_count_recent_bulk_sends88%domain/email.py
fetch_dropbox_dataget_dropbox_data88%domain/dropbox.py
get_live_leaderboard_commentarygenerate_leaderboard_commentary87%domain/ai.py
get_event_email_recipientsget_email_recipients87%domain/email.py
get_analyst_tipsgenerate_analyst_tips86%domain/ai.py
send_event_smtp_emailsend_event_email86%domain/email.py
get_monthly_actualsextract_monthly_actuals86%domain/scoring.py
generate_whatsapp_leaderboard_imagegenerate_leaderboard_image85%domain/image_export.py
get_event_email_configget_email_config84%domain/email.py
set_user_emailget_user_by_email84%domain/auth.py
get_forecastget_user_forecast83%domain/forecasts.py
get_annual_pot_commentarygenerate_annual_commentary82%domain/ai.py
send_event_resend_emailsend_event_email82%domain/email.py
get_cache_keyget_cache82%domain/cache.py
get_profile_rankings_commentarygenerate_rankings_commentary81%domain/ai.py
validate_login_tokenvalidate_session_token81%domain/auth.py
get_profile_badges_commentarygenerate_badges_commentary80%domain/ai.py
find_user_by_emailget_user_by_email80%domain/auth.py
get_user_fyi_leaderboard_preferencesget_user_fyi_preferences80%domain/settings.py
set_user_fyi_leaderboard_preferencesset_user_fyi_preferences80%domain/settings.py
get_locked_actualslock_actuals80%routers/admin.py
calculate_annual_leaderboardget_annual_leaderboard80%domain/leaderboard.py
calculate_all_time_leaderboardget_alltime_leaderboard79%domain/leaderboard.py
highlight_current_userget_current_user79%routers/pages.py
get_event_email_logget_recent_emails78%domain/email.py
save_locked_actualslock_actuals77%routers/admin.py
get_recent_event_email_logsget_recent_emails77%domain/email.py
get_all_forecastsget_all_forecasts_for_month77%domain/forecasts.py
delete_locked_actualsdelete_locked76%routers/admin.py
get_userget_all_users76%domain/users.py
get_previous_monthauto_lock_previous_month76%domain/scheduler.py
reserve_event_email_idempotency_reserve_idempotency76%domain/email.py
render_recent_final_results_panelrecent_results_panel75%routers/fragments.py
get_cached_dataget_cache75%domain/cache.py
_get_event_email_settingget_recent_emails75%domain/email.py
get_bonus_rules_for_monthget_bonus_rules75%domain/settings.py
display_detailed_monthly_leaderboardget_monthly_leaderboard75%domain/leaderboard.py
get_user_profile_statsprofile_stats74%routers/fragments.py
update_settingsget_settings74%domain/settings.py
set_user_must_change_passwordset_user_password74%domain/auth.py
save_leaderboard_stateleaderboard_page74%routers/pages.py
change_password_pageneeds_password_change73%domain/auth.py
check_event_email_rate_limit_check_rate_limit73%domain/email.py
calculate_monthly_scoresbuild_monthly_scores73%domain/scoring.py
get_cached_roastget_cache72%domain/cache.py
generate_login_tokengenerate_ai_content72%domain/ai.py
get_latest_sales_dateget_latest_month_data71%domain/dropbox.py
get_mtd_dataget_dropbox_data71%domain/dropbox.py
send_event_notification_emailsend_event_email71%domain/email.py
delete_login_tokendelete_locked71%routers/admin.py
get_all_locked_actualslock_actuals71%routers/admin.py
get_openai_clientget_email_recipients70%domain/email.py
get_user_current_rankget_current_user70%routers/pages.py
display_live_detailed_leaderboardget_live_mtd_leaderboard70%domain/leaderboard.py
clear_cacheget_cache70%domain/cache.py
can_send_reset_email_nowsend_event_email70%domain/email.py
admin_pageadmin_logs70%routers/admin.py

Other Missing (review needed)

SectionFunctionSize
Admin Pages_calculate_monthly_scores_live18L
Admin Pageswarm_runtime_leaderboard_caches19L
Download Helperscreate_download_button34L
Formatting & UI Utilfmt_currency5L
Formatting & UI Utilfmt_percent5L
Formatting & UI Utilfmt_number5L
Leaderboard Displayget_sa_time3L
Leaderboard Display_cached_dropbox_fetch34L
Leaderboard Displayforce_refresh_dropbox_data19L
Leaderboard Displayget_sales_daily_preview39L
Leaderboard Displayextract_latest_sales_date_from_df21L
Leaderboard Displaybuild_runtime_page_context16L
Leaderboard Displayget_sidebar_data_status17L
Leaderboard Displayget_user_leaderboard_rank_summary127L
Leaderboard Displayget_precomputed_scores14L
Leaderboard Displayget_all_precomputed_scores22L
Leaderboard Displayprecompute_and_store_monthly_scores36L
Othercalculate_forecast_twins117L
Othercalculate_monthly_breakdown107L
Otherparse_formatted_number10L
Otherformat_with_commas6L
Otherget_rank_display15L
Otherparse_num14L
Otherget_stored_badges11L
Otherstore_badges13L
Otherget_pwa_build_version30L
Othermain508L
Rank Displayget_rank_display_badge11L
Rank Displayget_sidebar_ranks26L
WhatsApp Export_calc_col_widths19L

Migrated (33 exact matches)

FunctionOldNew Location
_due_reminder_slots_for_nowapp.py:L6300domain/scheduler.py
_format_month_labelapp.py:L4044domain/email.py
_get_forecast_auto_close_due_atapp.py:L6207domain/scheduler.py
_parse_iso_datetimeapp.py:L4695domain/scheduler.py
assign_ranking_pointsapp.py:L7002domain/scoring.py
auto_lock_previous_monthapp.py:L6106domain/scheduler.py
auto_open_next_month_forecastapp.py:L6158domain/scheduler.py
calculate_absolute_errorapp.py:L6997domain/scoring.py
calculate_bonus_pointsapp.py:L7007domain/scoring.py
carry_over_forecastsapp.py:L5918domain/scheduler.py
create_userapp.py:L5486domain/users.py
forecast_pageapp.py:L8358routers/pages.py
generate_ai_contentapp.py:L490domain/ai.py
get_all_forecasts_for_monthapp.py:L6019domain/forecasts.py
get_all_usersapp.py:L5678domain/users.py
get_bonus_rulesapp.py:L5865domain/settings.py
get_dbapp.py:L3754domain/firebase.py
get_settingsapp.py:L5701domain/settings.py
get_user_achievementsapp.py:L7356domain/achievements.py
leaderboard_pageapp.py:L9612routers/pages.py
login_pageapp.py:L8096routers/pages.py
profile_pageapp.py:L13632routers/pages.py
reserve_scheduler_run_slotapp.py:L4785domain/scheduler.py
reset_user_passwordapp.py:L5554domain/users.py
run_auto_close_forecast_windowapp.py:L6251domain/scheduler.py
run_deadline_submission_remindersapp.py:L6319domain/scheduler.py
run_weekly_leaderboard_updatesapp.py:L6386domain/scheduler.py
save_bonus_rulesapp.py:L5875domain/settings.py
save_forecastapp.py:L5959domain/forecasts.py
scoring_rules_pageapp.py:L14561routers/pages.py
set_user_passwordapp.py:L5588domain/auth.py
update_user_statusapp.py:L5529domain/users.py
verify_passwordapp.py:L5696domain/auth.py

Generated by SafairBru Gap Analysis · MC-392