mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-18 12:46:43 +02:00
fix(analytics): reduce sync to 2x/day, remove frontend polling for cleaner charts
This commit is contained in:
1 parent
a460255b93
commit
8b13748f13
2 files changed
+5
-6
No files matched your search
@@ -10,8 +10,8 @@ import { apiRequest } from '@/lib/queryClient';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
|
||||
/** Maximum staleness before triggering an auto-refresh (6 hours in ms). */
|
||||
const STALE_THRESHOLD_MS = 6 * 60 * 60 * 1000;
|
||||
/** Maximum staleness before triggering an auto-refresh (12 hours in ms). */
|
||||
const STALE_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
||||
|
||||
export function AnalyticsDashboard() {
|
||||
const [selectedPageId, setSelectedPageId] = useState<string | null>(null);
|
||||
@@ -40,7 +40,6 @@ export function AnalyticsDashboard() {
|
||||
const { data: history = [], isLoading: isLoadingHistory } = useQuery<any[]>({
|
||||
queryKey: [`/api/analytics/pages/${selectedPageId}/history`],
|
||||
enabled: !!selectedPageId,
|
||||
refetchInterval: 30_000, // Poll every 30 seconds
|
||||
});
|
||||
|
||||
// Refresh Mutation
|
||||
|
||||
+3
-3
@@ -10,8 +10,8 @@ export function startTokenCron() {
|
||||
});
|
||||
console.log('[Cron] Token refresh job scheduled (0 0 * * *).');
|
||||
|
||||
// Run every 6 hours — Analytics sync for all pages
|
||||
cron.schedule('0 */6 * * *', async () => {
|
||||
// Run twice daily (08:00 and 20:00) — Analytics sync for all pages
|
||||
cron.schedule('0 8,20 * * *', async () => {
|
||||
console.log('[Cron] Running analytics sync for all pages...');
|
||||
try {
|
||||
await AnalyticsService.syncAllPages();
|
||||
@@ -19,5 +19,5 @@ export function startTokenCron() {
|
||||
console.error('[Cron] Analytics sync failed:', error);
|
||||
}
|
||||
});
|
||||
console.log('[Cron] Analytics sync job scheduled (0 */6 * * *).');
|
||||
console.log('[Cron] Analytics sync job scheduled (0 8,20 * * *).');
|
||||
}
|
||||
Reference in new issue
Block a user