// ---------- Launch calendar ---------- // RNDSystems launches every 2nd & 4th Tuesday · BT launches every 3rd Tuesday. // Code freeze: Friday at 10:00 AM, the week of the launch (Friday before launch day). const UAT_NOW = new Date(); UAT_NOW.setHours(0, 0, 0, 0); function nthTuesday(y, m, n) { const d = new Date(y, m, 1); const first = ((2 - d.getDay()) + 7) % 7; // offset to first Tuesday return new Date(y, m, 1 + first + (n - 1) * 7); } function upcomingLaunches(ordinals, count) { const out = []; for (let i = 0; i < 18 && out.length < count; i++) { const m = UAT_NOW.getMonth() + i; const y = UAT_NOW.getFullYear() + Math.floor(m / 12); const mm = m % 12; for (const n of ordinals) { const launch = nthTuesday(y, mm, n); if (launch >= UAT_NOW) out.push({ launch, freeze: new Date(launch.getTime() - 4 * 86400000) }); } } return out.sort((a, b) => a.launch - b.launch).slice(0, count); } const RDNS_LAUNCHES = upcomingLaunches([2, 4], 3); const BT_LAUNCHES = upcomingLaunches([3], 3); const fmtD = d => d.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" }); const fmtDy = d => d.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" }); const daysUntil = d => Math.round((d - UAT_NOW) / 86400000); // global next freeze (whichever comes first) const NEXT_FREEZE = RDNS_LAUNCHES[0].freeze < BT_LAUNCHES[0].freeze ? { ...RDNS_LAUNCHES[0], site: "RNDSystems" } : { ...BT_LAUNCHES[0], site: "BT" }; // ---------- Grouping (by launch cycle) ---------- function siteOf(t) { const first = ((t.desc || "").split("|")[0] || "").trim().toLowerCase(); if (/^rnd|^r&d/.test(first)) return "RNDSystems"; if (/^bt\b|^bio/.test(first)) return "BT"; if (/^wms/.test(first)) return "WMS"; if (/^sbd|^spd|^spatial/.test(first)) return "SBD"; return "Other"; } const SITE_ORDER = { "RNDSystems": 10, "BT": 11, "WMS": 12, "SBD": 13 }; const STATE_OPTIONS = ["Draft", "Ready", "Work in Progress", "Peer Review", "QA Testing", "UAT Testing", "Approved", "Awaiting Deployment", "Complete", "Cancelled"]; // priority within a launch section: outreach action needed first, then state readiness const ACTION_ORDER = { 0: 0, 1: 1, 2: 2, 4: 3, 3: 4 }; const STATE_ORDER = { "UAT Testing": 0, "Work in Progress": 1, "Peer Review": 2, "QA Testing": 3, "Draft": 4, "Ready": 5 }; // "sent to bottom" memory (order matters — the order you sent them down) const BOTTOM_KEY = "uat-outreach-bottom-v1"; let bottomOrder = []; try { bottomOrder = JSON.parse(localStorage.getItem(BOTTOM_KEY) || "[]"); } catch { bottomOrder = []; } function saveBottom() { localStorage.setItem(BOTTOM_KEY, JSON.stringify(bottomOrder)); } function moveBottom(id) { if (bottomOrder.includes(id)) bottomOrder = bottomOrder.filter(x => x !== id); else bottomOrder.push(id); saveBottom(); uatRender(); } // ---------- Filters ---------- const els = { statusFilter: document.getElementById("statusFilter"), stateFilter: document.getElementById("stateFilter"), epicFilter: document.getElementById("epicFilter"), search: document.getElementById("search"), showDone: document.getElementById("showDoneToggle"), list: document.getElementById("list"), }; let hideApproved = false; let showHidden = false; const isVisibleState = t => !HARD_EXCLUDED.has(t.state) && (showHidden || !IGNORED_STATES.has(t.state)); function populateFilters() { const states = [...new Set(tickets.map(t => t.state).filter(s => s && !HARD_EXCLUDED.has(s) && (showHidden || !IGNORED_STATES.has(s))))].sort(); const epics = [...new Set(tickets.map(t => t.epic).filter(Boolean))].sort(); const prevState = els.stateFilter.value; const prevEpic = els.epicFilter.value; els.stateFilter.innerHTML = '' + states.map(s => ``).join(""); els.epicFilter.innerHTML = '' + epics.map(s => ``).join(""); if (states.includes(prevState)) els.stateFilter.value = prevState; if (epics.includes(prevEpic)) els.epicFilter.value = prevEpic; } function visibleTickets() { const sf = els.statusFilter.value; const ts = els.stateFilter.value; const ep = els.epicFilter.value; const q = els.search.value.trim().toLowerCase(); return tickets.filter(t => { if (!isVisibleState(t)) return false; if (hideApproved && uatStatusOf(t) === 3 && sf === "") return false; if (sf !== "" && uatStatusOf(t) !== Number(sf)) return false; if (ts && t.state !== ts) return false; if (ep && t.epic !== ep) return false; if (q && !(t.ticket + " " + t.desc + " " + t.assigned_to + " " + t.opened_by + " " + t.epic + " " + (t.watch_list || "")).toLowerCase().includes(q)) return false; return true; }); } // ---------- Render (organized by next launch per site) ---------- function escUat(s) { return (s || "").replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c])); } function uatRender() { const vis = visibleTickets(); vis.forEach(t => { t.site = siteOf(t); }); // summary (counts over all tickets) const counts = [0, 0, 0, 0, 0]; const active = tickets.filter(t => isVisibleState(t)); active.forEach(t => counts[uatStatusOf(t)]++); for (let i = 0; i < 5; i++) document.getElementById("cnt" + i).textContent = counts[i]; const done = counts[3], total = active.length; const pct = total ? Math.round((done / total) * 100) : 0; document.getElementById("prog").style.width = pct + "%"; document.getElementById("progLabel").textContent = total ? `${done} of ${total} approved (${pct}%) · ${counts[2]} waiting on a response` : ""; // freeze banner (top of page) const bf = document.getElementById("uatBanner"); if (bf) { const n = daysUntil(NEXT_FREEZE.freeze); if (n >= 0 && n <= 7) { bf.style.display = "flex"; bf.innerHTML = `⚠️ Code freeze: ${fmtD(NEXT_FREEZE.freeze)} at 10:00 AM (${n === 0 ? "TODAY" : n + " day" + (n === 1 ? "" : "s") + " from now"}) → launch ${escUat(NEXT_FREEZE.site)} on ${fmtD(NEXT_FREEZE.launch)} · make sure testers are booked & approved stories are ready`; } else bf.style.display = "none"; } // launch calendar cards const lc = document.getElementById("launchCards"); if (lc) { const siteCount = s => vis.filter(t => t.site === s).length; const card = (name, rule, launches, count) => { const hot = daysUntil(launches[0].freeze) <= 7; return `