Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/worldmonitor/news/v1/summarize-article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export async function summarizeArticle(
.replace(/<reflection>[\s\S]*?<\/reflection>/gi, '')
.trim();

// Strip unterminated thinking blocks (no closing tag)
rawContent = rawContent
.replace(/<think>[\s\S]*/gi, '')
.replace(/<\|thinking\|>[\s\S]*/gi, '')
Expand Down
2 changes: 1 addition & 1 deletion src/components/TradePolicyPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class TradePolicyPanel extends Panel {
return `<div class="economic-empty">${t('components.tradePolicy.noTariffData')}</div>`;
}

const rows = this.tariffsData.datapoints.map(d =>
const rows = [...this.tariffsData.datapoints].sort((a, b) => b.year - a.year).map(d =>
`<tr>
<td>${d.year}</td>
<td>${d.tariffRate.toFixed(1)}%</td>
Expand Down
18 changes: 8 additions & 10 deletions tests/ttl-acled-ais-guards.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ describe('ACLED shared cache layer', () => {
'Cache key should include event types, start date, end date');
});

it('checks Redis cache before upstream API call', () => {
const cacheCheckIdx = src.indexOf('getCachedJson(cacheKey)');
const fetchIdx = src.indexOf('fetch(`${ACLED_API_URL}');
assert.ok(cacheCheckIdx > -1, 'Should check Redis cache');
assert.ok(fetchIdx > -1, 'Should call ACLED API');
assert.ok(cacheCheckIdx < fetchIdx,
'Cache check should come before upstream fetch');
it('uses cachedFetchJson to check Redis cache before upstream API call', () => {
assert.match(src, /cachedFetchJson\s*<.*>\s*\(cacheKey/,
'Should use cachedFetchJson which handles cache check + coalescing');
assert.ok(src.includes('fetch(`${ACLED_API_URL}'),
'Should call ACLED API inside the fetcher');
});

it('uses 15-minute cache TTL', () => {
Expand All @@ -71,9 +69,9 @@ describe('ACLED shared cache layer', () => {
'Should gracefully degrade when ACLED_ACCESS_TOKEN is not set');
});

it('writes to cache on successful fetch', () => {
assert.match(src, /setCachedJson\(cacheKey, events, ACLED_CACHE_TTL\)/,
'Should cache successful results');
it('caches successful results via cachedFetchJson', () => {
assert.match(src, /cachedFetchJson/,
'Should use cachedFetchJson which writes to cache automatically on successful fetch');
});

it('caches empty successful responses to avoid repeated cache misses', () => {
Expand Down