perf: cache-only strategy for list views, cache-then-cw for single fetch

- Add data-source hierarchy to opportunity manager (cache-only, cache-then-cw, cw-first)
- fetchPages/search/fetchByCompany use cache-only: Redis → DB (no CW calls)
- fetchItem uses cache-then-cw by default, cw-first when fresh=true
- Add idleTimeout: 255 to Bun.serve to prevent request timeouts
- Map CW status 57 (04. Confirmed Quote) to Active equivalency
- Add computeCacheTTL algorithm and opportunityCache module
This commit is contained in:
2026-03-02 21:12:44 -06:00
parent 7411310083
commit fe71248e88
7 changed files with 1092 additions and 29 deletions
+12
View File
@@ -178,6 +178,18 @@ interface EventTypes {
staleCount: number;
}) => void;
// Cache Events
"cache:opportunities:refresh:started": (data: {
totalOpportunities: number;
}) => void;
"cache:opportunities:refresh:completed": (data: {
totalOpportunities: number;
activitiesRefreshed: number;
companiesRefreshed: number;
skipped: number;
}) => void;
"cache:opportunities:refresh:error": (data: { error: unknown }) => void;
// ConnectWise User Defined Fields Events
"cw:udf:refresh:started": () => void;
"cw:udf:refresh:completed": (data: { count: number }) => void;