No-Flab Brief
  • Home

On this page

  • Latest Briefings

No-Flab Brief Dashboard

Latest Briefings

**Total Articles:** 1000 | **Latest Update:** 2026-01-04 11:54:34+00:00
Loading ITables v2.6.2 from the internet... (need help?)
Source Code
---
title: "No-Flab Brief Dashboard"
format:
  html:
    page-layout: full
---

## Latest Briefings

```{python}
#| echo: false
#| warning: false

import pandas as pd
import os
from itables import show
from datetime import datetime
from IPython.display import display, HTML

# Path to data (relative to serve/ directory where this file sits)
# In CI, files are copied to static/data, but for local dev we might look elsewhere.
# We'll check multiple locations.

possible_paths = [
    "../static/data/articles.parquet",  # Local dev / specific structure
    "../sources/no_flab_brief/articles.parquet", # Original source location
    "./data/articles.parquet" # Deployed location pattern if copied
]

df = None
loaded_path = ""

for path in possible_paths:
    if os.path.exists(path):
        try:
            df = pd.read_parquet(path)
            loaded_path = path
            break
        except Exception as e:
            print(f"Failed to read {path}: {e}")

if df is not None:
    # Basic Preprocessing
    if 'published_date' in df.columns:
        df['published_date'] = pd.to_datetime(df['published_date'], format='ISO8601')
        df = df.sort_values('published_date', ascending=False)
    
    # Display top metrics
    total_articles = len(df)
    latest_date = df['published_date'].max() if 'published_date' in df.columns else "N/A"
    
    print(f"**Total Articles:** {total_articles} | **Latest Update:** {latest_date}")
    print("")
    
    # Select key columns for display
    cols_to_show = ['published_date', 'title', 'source', 'beat', 'region', 'impact_score', 'link']
    display_df = df[[c for c in cols_to_show if c in df.columns]].copy()
    
    # Make links clickable if 'link' exists
    if 'link' in display_df.columns:
        display_df['title'] = display_df.apply(lambda x: f'<a href="{x["link"]}" target="_blank">{x["title"]}</a>', axis=1)
        display_df = display_df.drop(columns=['link'])
    
    # Show interactive table using itables (datatables wrapper)
    # itables provides client-side filtering and sorting in the browser
    show(display_df, classes="display nowrap compact", scrollX=True, pageLength=25, column_filters="header")

else:
    print("⚠️ Data not found. Ensure 'articles.parquet' is generated and available in static/data or sources.")
    print(f"Checked paths: {possible_paths}")

```