Fix misleading "Pending audit" label on excluded posts in Overview

The Overview/Content tab's Posts table labeled every unaudited Real
Eng % as "Pending audit", including the 10/07 repost and other
REPOST_DATES/NON_CAMPAIGN_DATES posts that are deliberately never
audited (see engagement_audit.py) rather than simply not gotten to
yet. That read as an incomplete job rather than an intentional
exclusion. Those dates now show "Excluded" instead, matching the
wording already used in the Reports tab's All Posts and Core Message
treatment of the same dates. Fixed in both the initial table render
and the month-dropdown callback path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
beantownbabeandClaude Sonnet 5 committed 2026-09-30 12:05:04 +02:00
1 parent 1718a56ea6
commit 9eb636bf79
1 file changed
+25 -3
+25 -3
View File
@@ -537,11 +537,24 @@ def refresh_data():
def _posts_table_records(selected_month):
"""Rows for the All Posts table, optionally filtered to one 'YYYY-MM' month value."""
df = posts[post_table_cols].copy()
source = posts
if selected_month and selected_month != "all":
year, month = (int(part) for part in selected_month.split("-"))
df = df[(posts["Created date"].dt.year == year) & (posts["Created date"].dt.month == month)]
mask = (posts["Created date"].dt.year == year) & (posts["Created date"].dt.month == month)
df = df[mask]
source = posts[mask]
# A repost/non-campaign post's Real Eng % is None because it's deliberately
# never audited (see engagement_audit.py), not because the audit is behind —
# "Pending audit" on one of these would misread as an incomplete job rather
# than a deliberate exclusion, so those dates get "Excluded" instead, same
# wording as the Reports tab's All Posts/Core Message treatment of the same
# dates.
excluded_mask = source["Created date"].dt.strftime("%Y-%m-%d").isin(REPOST_DATES | NON_CAMPAIGN_DATES)
df["Created date"] = df["Created date"].dt.strftime("%d/%m/%Y")
df["Real Eng %"] = df["Real Eng %"].apply(lambda v: "Pending audit" if pd.isna(v) else v)
df["Real Eng %"] = [
(v if not pd.isna(v) else ("Excluded" if excluded else "Pending audit"))
for v, excluded in zip(df["Real Eng %"], excluded_mask)
]
return df.to_dict("records")
@@ -651,8 +664,17 @@ def refresh_data():
_posts_table_df = posts[post_table_cols].copy()
# A repost/non-campaign post's Real Eng % is None because it's deliberately never
# audited (see engagement_audit.py), not because the audit is behind — "Pending
# audit" on one of these would misread as an incomplete job rather than a
# deliberate exclusion, so those dates get "Excluded" instead, same wording as
# the Reports tab's All Posts/Core Message treatment of the same dates.
_excluded_dates_mask = posts["Created date"].dt.strftime("%Y-%m-%d").isin(REPOST_DATES | NON_CAMPAIGN_DATES)
_posts_table_df["Created date"] = _posts_table_df["Created date"].dt.strftime("%d/%m/%Y")
_posts_table_df["Real Eng %"] = _posts_table_df["Real Eng %"].apply(lambda v: "Pending audit" if pd.isna(v) else v)
_posts_table_df["Real Eng %"] = [
(v if not pd.isna(v) else ("Excluded" if excluded else "Pending audit"))
for v, excluded in zip(_posts_table_df["Real Eng %"], _excluded_dates_mask)
]
content_tab = dbc.Container([
dbc.Card([