Skip to content

Real-time dashboard for monitoring global news, markets, and geopolitical events

TypeScript

Fix Intel panel data and add timespan to GDELT queries

Sean Thielen-Esparza39ed75c43129
diff --git a/src/lib/api/news.ts b/src/lib/api/news.ts
index 038c2c3..fd93ed2 100644
--- a/src/lib/api/news.ts
+++ b/src/lib/api/news.ts
@@ -101,11 +101,11 @@ export async function fetchCategoryNews(category: NewsCategory): Promise<NewsIte
};
try {
- // Add English language filter and source country filter for relevant results
+ // Add English language filter and timespan for fresh results
const baseQuery = categoryQueries[category];
const fullQuery = `${baseQuery} sourcelang:english`;
- // Build the raw GDELT URL (don't pre-encode query - let encodeURIComponent handle the whole URL once)
- const gdeltUrl = `https://api.gdeltproject.org/api/v2/doc/doc?query=${fullQuery}&mode=artlist&maxrecords=20&format=json&sort=date`;
+ // Build the raw GDELT URL with timespan=7d to get recent articles
+ const gdeltUrl = `https://api.gdeltproject.org/api/v2/doc/doc?query=${fullQuery}&timespan=7d&mode=artlist&maxrecords=20&format=json&sort=date`;
// Use proxy to avoid CORS - encode the whole URL once
const proxyUrl = CORS_PROXY_URL + encodeURIComponent(gdeltUrl);
diff --git a/src/lib/components/panels/IntelPanel.svelte b/src/lib/components/panels/IntelPanel.svelte
index f76b93d..dfa22c0 100644
--- a/src/lib/components/panels/IntelPanel.svelte
+++ b/src/lib/components/panels/IntelPanel.svelte
@@ -1,27 +1,55 @@
<script lang="ts">
import { Panel, Badge } from '$lib/components/common';
import { getRelativeTime } from '$lib/utils';
+ import { intelNews } from '$lib/stores';
+ import type { NewsItem } from '$lib/types';
+
+ type SourceType = 'osint' | 'govt' | 'think-tank' | 'defense' | 'regional' | 'cyber';
interface IntelItem {
id: string;
title: string;
link: string;
source: string;
- sourceType: 'osint' | 'govt' | 'think-tank' | 'defense' | 'regional' | 'cyber';
+ sourceType: SourceType;
regions: string[];
topics: string[];
pubDate?: string;
isPriority?: boolean;
}
- interface Props {
- items?: IntelItem[];
- loading?: boolean;
- error?: string | null;
+ // Subscribe to intel news store directly
+ const storeItems = $derived($intelNews.items);
+ const loading = $derived($intelNews.loading);
+ const error = $derived($intelNews.error);
+
+ // Infer source type from source name
+ function inferSourceType(source: string): SourceType {
+ const s = source.toLowerCase();
+ if (s.includes('cisa') || s.includes('krebs') || s.includes('cyber')) return 'cyber';
+ if (s.includes('bellingcat')) return 'osint';
+ if (s.includes('defense') || s.includes('war') || s.includes('military')) return 'defense';
+ if (s.includes('diplomat') || s.includes('monitor')) return 'regional';
+ if (s.includes('white house') || s.includes('fed') || s.includes('sec') || s.includes('dod')) return 'govt';
+ return 'think-tank';
}
- let { items = [], loading = false, error = null }: Props = $props();
+ // Transform NewsItem to IntelItem
+ function transformToIntelItem(item: NewsItem): IntelItem {
+ return {
+ id: item.id,
+ title: item.title,
+ link: item.link,
+ source: item.source,
+ sourceType: inferSourceType(item.source),
+ regions: item.region ? [item.region] : [],
+ topics: item.topics || [],
+ pubDate: item.pubDate,
+ isPriority: item.isAlert
+ };
+ }
+ const items = $derived(storeItems.map(transformToIntelItem));
const count = $derived(items.length);
function getSourceBadgeVariant(