// ---------- 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 `

${name}

${rule}
🚀 ${fmtDy(launches[0].launch)}  ·  🧊 freeze ${fmtD(launches[0].freeze)} 10 AM
${count} open ticket${count === 1 ? "" : "s"} in queue · next in ${daysUntil(launches[0].launch)} days
then ${launches.slice(1).map(l => fmtD(l.launch)).join(" · ")}
`; }; const both = [ { name: "🖥 RNDSystems", rule: "launches 2nd & 4th Tuesday", launches: RDNS_LAUNCHES, count: siteCount("RNDSystems") }, { name: "🧬 BT", rule: "launches 3rd Tuesday", launches: BT_LAUNCHES, count: siteCount("BT") } ] .sort((a, b) => a.launches[0].launch - b.launches[0].launch); lc.innerHTML = both.map(c => card(c.name, c.rule, c.launches, c.count)).join(""); } if (!vis.length) { els.list.innerHTML = tickets.length ? '
No tickets match the current filters.
' : '
📂 No data loaded yet.
Click "📂 Load weekly CSV" in the toolbar (or drag & drop your weekly ServiceNow export anywhere on this tab) to get started.
'; updateUatBadge(); return; } // priority sort inside a section: normal order first, "sent to bottom" tickets last const cmp = (a, b) => { const ab = bottomOrder.indexOf(a.ticket), bb = bottomOrder.indexOf(b.ticket); const aB = ab === -1 ? 1 : 0, bB = bb === -1 ? 1 : 0; if (aB !== bB) return aB - bB; if (ab !== -1 && bb !== -1) return ab - bb; const sa = ACTION_ORDER[uatStatusOf(a)], sb = ACTION_ORDER[uatStatusOf(b)]; if (sa !== sb) return sa - sb; const ta = STATE_ORDER[a.state] ?? 99, tb = STATE_ORDER[b.state] ?? 99; if (ta !== tb) return ta - tb; return a.ticket.localeCompare(b.ticket); }; const bucketLaunch = site => site === "RNDSystems" ? RDNS_LAUNCHES[0] : (site === "BT" ? BT_LAUNCHES[0] : null); const siteRule = { RNDSystems: "2nd & 4th Tuesday", BT: "3rd Tuesday" }; const withLaunch = [], without = []; for (const s of new Set(vis.map(t => t.site))) (bucketLaunch(s) ? withLaunch : without).push(s); // nearest launch first — the section you have to worry about now comes on top withLaunch.sort((a, b) => daysUntil(bucketLaunch(a).launch) - daysUntil(bucketLaunch(b).launch) || (SITE_ORDER[a] ?? 98) - (SITE_ORDER[b] ?? 98)); without.sort((a, b) => (SITE_ORDER[a] ?? 98) - (SITE_ORDER[b] ?? 98) || a.localeCompare(b)); const keys = [...withLaunch, ...without]; const nextSite = withLaunch[0] || null; const colhead = `
TicketDescriptionStateTester (watch list)DevOutreach status
`; const row = t => { const s = uatStatusOf(t); const btnLabels = ["Reached out", "Waiting", "Approved"]; const isUAT = /^UAT/i.test(t.state || ""); const isBottom = bottomOrder.includes(t.ticket); return `
${escUat(t.ticket)} ${escUat(t.desc) || "—"} ${escUat(t.state) || "—"} ${t.watch_list ? `${escUat(t.watch_list)}` : "—"} ${t.assigned_to ? `→ ${escUat(t.assigned_to)}` : "—"} ${[1, 2, 3].map(i => `` ).join("")}
${(isUAT || t.note) ? `
${isUAT ? `` : ""} ${t.note ? `“${escUat(t.note)}”` : ""}
` : ""}
`; }; const section = site => { const list = vis.filter(t => t.site === site).sort(cmp); if (!list.length) return ""; const launch = bucketLaunch(site); let head = `
${site === "RNDSystems" ? "🖥" : (site === "BT" ? "🧬" : "📦")} ${escUat(site)}${site === nextSite ? '⏭ NEXT UP' : ""}`; if (launch) { const n = daysUntil(launch.launch); const cls = n <= 7 ? "urgent" : (n <= 21 ? "soon" : "later"); head += `→ launch ${fmtDy(launch.launch)} 🧊 freeze ${fmtD(launch.freeze)} · 10 AM ${n === 0 ? "LAUNCH TODAY" : n + " day" + (n === 1 ? "" : "s") + " out"} ${siteRule[site]}`; } else { head += `no launch cycle tracked here — keep as a separate queue`; } head += `${list.length} ticket${list.length === 1 ? "" : "s"}
`; const main = list.filter(t => !bottomOrder.includes(t.ticket)).map(row).join(""); const bots = list.filter(t => bottomOrder.includes(t.ticket)); const bot = bots.length ? `
⬇ sent to bottom · ${bots.length}
${bots.map(row).join("")}
` : ""; return `
${head} ${colhead} ${main} ${bot}
`; }; els.list.innerHTML = keys.map(section).join(""); updateUatBadge(); } function updateUatBadge() { const b = document.getElementById("uatBadge"); if (!b) return; if (!tickets.length) { b.textContent = "🚀"; return; } const action = tickets.filter(t => { const s = siteOf(t); return isVisibleState(t) && (s === "RNDSystems" || s === "BT") && uatStatusOf(t) === 0; }).length; b.textContent = action > 0 ? `⚠ ${action}` : "🚀"; }