Files
Ten31-Portal/frontend/public/sw.js
T
Jonathan KirkwoodandClaude Opus 4.8 099459b2f3 0.2.25: batch historical eNAV backfill + collapsible investor chart
Add POST /api/import/capital-accounts/batch: upload several of a fund's
eNAV workbooks at once; each file's ALLOC SI roster is auto-matched to
existing members (by fund-admin investor ID, else name/username) and their
capital statement is saved at that file's own as-of date, building
trend-lines without replacing the latest figures. Members not already in
the portal are skipped and reported per file (never created). Capital
statements only -- holdings/NAV are untouched. One bad file (wrong
password, no ALLOC SI, unreadable date) is reported per-file and does not
abort the rest.

Import page gains a "Backfill historical capital" batch section (fund
picker, multi-file .xlsx input, shared password, per-file results table).

Investor portal "Capital over time" chart is now collapsed by default and
expands per fund (first login opens clean); applies to InvestorHome and
the admin Investor View via the shared component.

Tests: backend/tests/test_capital_batch.py (2). Full suite 17 passed;
frontend tsc clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 18:47:01 -05:00

57 lines
1.7 KiB
JavaScript

// Ten31 Portal service worker. Deliberately conservative so it never serves a stale app:
// - navigations are network-first (always get the latest index.html), cache only as offline fallback
// - content-hashed /assets/* are cache-first (immutable, safe forever)
// - /api/* is never cached
// Bump CACHE on each release so old entries are purged.
const CACHE = 'ten31-portal-0.2.25'
self.addEventListener('install', () => self.skipWaiting())
self.addEventListener('activate', (event) => {
event.waitUntil(
(async () => {
const keys = await caches.keys()
await Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
await self.clients.claim()
})(),
)
})
self.addEventListener('fetch', (event) => {
const req = event.request
if (req.method !== 'GET') return
const url = new URL(req.url)
if (url.origin !== self.location.origin) return
if (url.pathname.startsWith('/api/')) return
if (req.mode === 'navigate') {
event.respondWith(
(async () => {
try {
const fresh = await fetch(req)
const cache = await caches.open(CACHE)
cache.put('/', fresh.clone())
return fresh
} catch {
const cache = await caches.open(CACHE)
return (await cache.match('/')) || Response.error()
}
})(),
)
return
}
if (url.pathname.startsWith('/assets/')) {
event.respondWith(
(async () => {
const cache = await caches.open(CACHE)
const hit = await cache.match(req)
if (hit) return hit
const res = await fetch(req)
if (res.ok) cache.put(req, res.clone())
return res
})(),
)
}
})