fixes related to automation and celery schedules
This commit is contained in:
@@ -32,7 +32,8 @@ import {
|
||||
CheckCircleIcon,
|
||||
ClockIcon,
|
||||
PaperPlaneIcon,
|
||||
ArrowRightIcon
|
||||
ArrowRightIcon,
|
||||
TimeIcon
|
||||
} from '../../icons';
|
||||
|
||||
/**
|
||||
@@ -77,9 +78,31 @@ const AutomationPage: React.FC = () => {
|
||||
const [globalProgress, setGlobalProgress] = useState<GlobalProgress | null>(null);
|
||||
const [stageProgress, setStageProgress] = useState<StageProgress[]>([]);
|
||||
const [initialSnapshot, setInitialSnapshot] = useState<InitialSnapshot | null>(null);
|
||||
|
||||
// Server time state - shows the actual time used for all operations
|
||||
const [serverTime, setServerTime] = useState<string | null>(null);
|
||||
const [serverTimezone, setServerTimezone] = useState<string>('UTC');
|
||||
|
||||
// Track site ID to avoid duplicate calls when activeSite object reference changes
|
||||
const siteId = activeSite?.id;
|
||||
|
||||
// Fetch and update server time every second
|
||||
useEffect(() => {
|
||||
const loadServerTime = async () => {
|
||||
try {
|
||||
const data = await automationService.getServerTime();
|
||||
setServerTime(data.server_time_formatted);
|
||||
setServerTimezone(data.timezone);
|
||||
} catch (error) {
|
||||
console.error('Failed to load server time:', error);
|
||||
}
|
||||
};
|
||||
|
||||
loadServerTime();
|
||||
const interval = setInterval(loadServerTime, 1000); // Update every second
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Calculate time remaining until next scheduled run
|
||||
@@ -588,12 +611,9 @@ const AutomationPage: React.FC = () => {
|
||||
</>
|
||||
)}
|
||||
<div className="h-4 w-px bg-white/25"></div>
|
||||
<div className="text-sm text-white/90">
|
||||
<span className="font-medium">Est:</span>{' '}
|
||||
<span className="font-semibold text-white">{estimate?.estimated_credits || 0} content pieces</span>
|
||||
{estimate && !estimate.sufficient && (
|
||||
<span className="ml-1 text-white/90 font-semibold">(Limit reached)</span>
|
||||
)}
|
||||
<div className="text-sm text-white inline-flex items-center gap-1">
|
||||
<TimeIcon className="size-3.5" />
|
||||
<span className="font-semibold tabular-nums">{serverTime ? serverTime.substring(0, 5) : '--:--'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -161,11 +161,8 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
},
|
||||
};
|
||||
|
||||
console.log('[AIAutomationSettings] Saving payload:', JSON.stringify(payload, null, 2));
|
||||
|
||||
// Save unified settings
|
||||
const updated = await updateUnifiedSiteSettings(siteId, payload);
|
||||
console.log('[AIAutomationSettings] Received updated settings:', JSON.stringify(updated.stages, null, 2));
|
||||
setSettings(updated);
|
||||
|
||||
// Save image settings
|
||||
@@ -816,6 +813,38 @@ export default function AIAutomationSettings({ siteId }: AIAutomationSettingsPro
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Scheduler Info Card - Full Width */}
|
||||
<Card className="p-4 bg-gray-50 dark:bg-gray-800/50 border-gray-200 dark:border-gray-700">
|
||||
<div className="flex items-start gap-4">
|
||||
<div className="p-2 bg-gray-200 dark:bg-gray-700 rounded-lg flex-shrink-0">
|
||||
<ClockIcon className="w-5 h-5 text-gray-600 dark:text-gray-400" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<div className="flex flex-wrap items-center gap-x-6 gap-y-2 mb-3">
|
||||
<div>
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide">System</span>
|
||||
<p className="text-sm font-semibold text-gray-900 dark:text-white">Background Task Queue</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide">Check Frequency</span>
|
||||
<p className="text-sm font-semibold text-gray-900 dark:text-white">Every 15 minutes</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide">Check Times</span>
|
||||
<p className="text-sm font-semibold text-gray-900 dark:text-white">:00, :15, :30, :45</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide">Timezone</span>
|
||||
<p className="text-sm font-semibold text-gray-900 dark:text-white">UTC</p>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-gray-600 dark:text-gray-400">
|
||||
The scheduler checks for due automations every 15 minutes. Your scheduled time will trigger within its 15-minute window (e.g., 14:35 triggers at the 14:30 check). Automations only run once per day — if already run, the next run is tomorrow. All times are UTC.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -419,4 +419,20 @@ export const automationService = {
|
||||
}> => {
|
||||
return fetchAPI(buildUrl('/production_stats/', { site_id: siteId }));
|
||||
},
|
||||
|
||||
/**
|
||||
* Get server time (UTC) used for all automation scheduling
|
||||
*/
|
||||
getServerTime: async (): Promise<{
|
||||
server_time: string;
|
||||
server_time_formatted: string;
|
||||
server_time_date: string;
|
||||
server_time_time: string;
|
||||
timezone: string;
|
||||
celery_timezone: string;
|
||||
use_tz: boolean;
|
||||
note: string;
|
||||
}> => {
|
||||
return fetchAPI(buildUrl('/server_time/'));
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user