diff --git a/cheddahbot/api.py b/cheddahbot/api.py index 7489261..eefaf18 100644 --- a/cheddahbot/api.py +++ b/cheddahbot/api.py @@ -184,11 +184,17 @@ async def get_link_building_tasks(): # -- Build focused groups -- - # need_cora: status "to do" AND LB Method = "Cora Backlinks" - need_cora = [ + # Split active vs closed + closed_statuses = {"complete", "closed", "done"} + active_lb = [ t for t in lb_tasks - if t["status"] == "to do" - and t["custom_fields"].get("LB Method") == "Cora Backlinks" + if not any(kw in t["status"] for kw in closed_statuses) + ] + + # need_cora: open LB tasks where LB Method = "Cora Backlinks" + need_cora = [ + t for t in active_lb + if t["custom_fields"].get("LB Method") == "Cora Backlinks" ] # recently_completed: closed/complete tasks with date_done in last 7 days @@ -215,13 +221,6 @@ async def get_link_building_tasks(): kv = t.get("kv_state") if kv is None or kv.get("state", "") in early_states: in_progress_not_started.append(t) - - # Group by company (exclude closed from the active list for the grid) - closed_statuses = {"complete", "closed", "done"} - active_lb = [ - t for t in lb_tasks - if not any(kw in t["status"] for kw in closed_statuses) - ] by_company: dict[str, list] = {} for task in active_lb: company = task["custom_fields"].get("Customer") or "Unassigned" diff --git a/dashboard/index.html b/dashboard/index.html index 042d6d7..bdc915a 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -151,6 +151,7 @@

📋 Cora Reports Needed

+ Z:\cora-inbox View LB
@@ -350,39 +351,35 @@ function updateGreeting() { // --- Overview Tab --- async function loadOverview() { - const [tasks, lb, pr, agents, health] = await Promise.all([ + const [tasks, agents, health] = await Promise.all([ fetchJSON('/tasks'), - fetchJSON('/tasks/link-building'), - fetchJSON('/tasks/press-releases'), fetchJSON('/agents'), fetchJSON('/system/health'), ]); // Cache for other tabs _cache.tasks = tasks; - _cache.lb = lb; - _cache.pr = pr; _cache.agents = agents; _cache.health = health; - // Stats - if (tasks) { + // Stats — derive LB/PR counts from tasks data + if (tasks && tasks.tasks) { document.getElementById('stat-total').textContent = tasks.count || 0; document.getElementById('stat-total-detail').textContent = `ClickUp tasks`; - } - if (lb) { - document.getElementById('stat-lb').textContent = lb.total || 0; - document.getElementById('stat-lb-detail').textContent = - `${lb.companies ? lb.companies.length : 0} companies`; - document.getElementById('badge-lb').textContent = lb.total || 0; - } - if (pr) { - document.getElementById('stat-pr').textContent = pr.total || 0; - document.getElementById('stat-pr-detail').textContent = - `${pr.companies ? pr.companies.length : 0} companies`; - document.getElementById('badge-pr').textContent = pr.total || 0; - } - if (tasks && tasks.tasks) { + + const lbTasks = tasks.tasks.filter(t => t.task_type === 'Link Building'); + const prTasks = tasks.tasks.filter(t => t.task_type === 'Press Release'); + + document.getElementById('stat-lb').textContent = lbTasks.length; + const lbCompanies = new Set(lbTasks.map(t => t.custom_fields?.Customer || 'Unassigned')); + document.getElementById('stat-lb-detail').textContent = `${lbCompanies.size} companies`; + document.getElementById('badge-lb').textContent = lbTasks.length; + + document.getElementById('stat-pr').textContent = prTasks.length; + const prCompanies = new Set(prTasks.map(t => t.custom_fields?.Customer || 'Unassigned')); + document.getElementById('stat-pr-detail').textContent = `${prCompanies.size} companies`; + document.getElementById('badge-pr').textContent = prTasks.length; + const companies = new Set(tasks.tasks.map(t => t.custom_fields?.Customer || 'Unassigned')); document.getElementById('stat-companies').textContent = companies.size; const names = [...companies].filter(c => c !== 'Unassigned').slice(0, 4).join(', '); @@ -443,12 +440,14 @@ async function loadOverview() { } } document.getElementById('this-month-count').textContent = thisMonth.length; - renderOverviewTable('overview-this-month', thisMonth, false); - } + renderOverviewTable('overview-this-month', thisMonth, true); - // -- Cora Reports Needed -- - if (lb && lb.need_cora) { - renderOverviewTable('overview-cora', lb.need_cora, false); + // -- Cora Reports Needed: LB tasks with LB Method = Cora Backlinks -- + const needCora = openTasks.filter(t => + t.task_type === 'Link Building' + && t.custom_fields?.['LB Method'] === 'Cora Backlinks' + ); + renderOverviewTable('overview-cora', needCora, false); } // Health inline