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
2 changes: 2 additions & 0 deletions backend/src/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async def lifespan(app: FastAPI):
job_id=f"automation_cycle_{account.id}",
minutes=scan_interval,
start_date=start_date,
name="Automation cycle",
)
started_count += 1

Expand All @@ -117,6 +118,7 @@ async def lifespan(app: FastAPI):
func=partial(safety_check_cycle, account_id=account.id),
job_id=f"safety_check_{account.id}",
seconds=45,
name="Safety check",
)
logger.info("safety_check_job_started", account_id=account.id, interval_seconds=45)

Expand Down
4 changes: 3 additions & 1 deletion backend/src/api/routers/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def get_account_scheduler_status(account_id: int, account_service: Account
except ResourceNotFoundError as e:
raise HTTPException(status_code=404, detail=str(e))

account_job_ids = {f"automation_cycle_{account_id}", f"safety_check_{account_id}"}
account_job_ids = {f"automation_cycle_{account_id}", f"safety_check_{account_id}", f"win_check_{account_id}"}
account_jobs = [j for j in scheduler_manager.get_jobs() if j.id in account_job_ids]

job_info = []
Expand Down Expand Up @@ -211,13 +211,15 @@ async def start_account_automation(account_id: int, account_service: AccountServ
job_id=f"automation_cycle_{account_id}",
minutes=scan_interval,
start_date=start_date,
name="Automation cycle",
)

if account.safety_check_enabled:
scheduler_manager.add_interval_job(
func=partial(safety_check_cycle, account_id=account_id),
job_id=f"safety_check_{account_id}",
seconds=45,
name="Safety check",
)

return create_success_response(data={"started": True, "account_id": account_id})
Expand Down
1 change: 1 addition & 0 deletions backend/src/services/scheduler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def _schedule_win_check_job(self, run_date: datetime) -> None:
func=self._win_check_callback,
job_id=self._win_check_job_id,
run_date=run_date,
name="Win check",
)

logger.info(
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/hooks/useScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ export const schedulerKeys = {
};

/**
* Fetch global scheduler status (whether the scheduler process is running)
* Fetch scheduler status, scoped to the selected account when available
*/
export function useSchedulerStatus() {
const selectedAccountId = useAccountStore((s) => s.selectedAccountId);

return useQuery({
queryKey: schedulerKeys.status,
queryKey: [...schedulerKeys.status, selectedAccountId],
queryFn: async () => {
const response = await api.get<SchedulerStatus>('/api/v1/scheduler/status');
const endpoint = selectedAccountId
? `/api/v1/accounts/${selectedAccountId}/scheduler/status`
: '/api/v1/scheduler/status';
const response = await api.get<SchedulerStatus>(endpoint);
if (!response.success) {
throw new Error(response.error || 'Failed to fetch scheduler status');
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ function JobCountdown({ job }: JobCountdownProps) {
}, [job.next_run]);

const jobLabel = job.name === 'scan_giveaways' ? 'Next scan' :
job.name === 'process_giveaways' ? 'Next process' : job.name;
job.name === 'process_giveaways' ? 'Next process' :
job.name === 'Automation cycle' ? 'Next scan' :
job.name === 'Safety check' ? 'Safety check' :
job.name === 'Win check' ? 'Win check' : job.name;

return (
<span className="flex items-center gap-1">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "steamselfgifter",
"version": "3.0.1",
"version": "3.0.2",
"private": true
}
Loading