Hide dormant years (2025) from the calendar year dropdown
Fixing the cumulative-total bug (previous commit) meant _team_fts_like now spans the export's full true window, which includes trailing months from before the person was active at all (Oct-Dec 2025, all zeros) - those were showing up as a selectable year with nothing in it. _team_years_with_activity keeps only years with at least one month of real net change or a real post; 2027 will appear automatically the first time it has either, same mechanism, no code change needed then. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25d1cba05f
commit
8f63b7dd53
1 file changed
+18
-2
@@ -2801,6 +2801,22 @@ def _team_posts_like(top_posts_df):
|
||||
return df
|
||||
|
||||
|
||||
def _team_years_with_activity(fts_like, posts_like):
|
||||
"""_available_years() returns every year with any row at all in the data - since
|
||||
_team_fts_like() now spans the export's full true window (fixed to stop dropping
|
||||
the May 30 gain), that includes trailing months from before the person was even
|
||||
active (e.g. Oct-Dec 2025, all zeros) which would otherwise clutter the year
|
||||
dropdown with a year where literally nothing happened. Keeps only years with at
|
||||
least one month of real net change or a real post - 2027 appears here
|
||||
automatically the first time it has either, no code change needed."""
|
||||
years = []
|
||||
for y in _available_years(fts_like, posts_like):
|
||||
monthly_net, monthly_posts, _, _ = _monthly_summary(fts_like, posts_like, y)
|
||||
if any(v != 0 for v in monthly_net.values()) or monthly_posts:
|
||||
years.append(y)
|
||||
return years
|
||||
|
||||
|
||||
def _team_calendar_grid(followers_daily_df, top_posts_df):
|
||||
"""Same month-box grid + day-tile row as the Overview/Followers tabs' "Follower
|
||||
Gains — Calendar", now actually interactive: a year dropdown (ready for 2027 as
|
||||
@@ -2810,7 +2826,7 @@ def _team_calendar_grid(followers_daily_df, top_posts_df):
|
||||
per-person callback registration."""
|
||||
fts_like = _team_fts_like(followers_daily_df)
|
||||
posts_like = _team_posts_like(top_posts_df)
|
||||
years = _available_years(fts_like, posts_like)
|
||||
years = _team_years_with_activity(fts_like, posts_like)
|
||||
if not years:
|
||||
return html.Div("No follower data.", className="text-muted")
|
||||
return html.Div([
|
||||
@@ -2852,7 +2868,7 @@ def _update_team_calendar(year, _month_clicks, name):
|
||||
posts_like = _team_posts_like(data["top_posts"])
|
||||
|
||||
if year is None:
|
||||
years = _available_years(fts_like, posts_like)
|
||||
years = _team_years_with_activity(fts_like, posts_like)
|
||||
if not years:
|
||||
raise PreventUpdate
|
||||
year = years[0]
|
||||
|
||||
Reference in new issue
Block a user