Skip to content

Commit b0316e9

Browse files
committed
uptime log
1 parent 198ce73 commit b0316e9

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

apps/uptime/src/actions.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,37 @@ type FetchFailure = {
4242

4343
export function lookupSchedule(
4444
id: string
45-
): Promise<ActionResult<{ id: string; url: string; websiteId: string | null }>> {
45+
): Promise<
46+
ActionResult<{ id: string; url: string; websiteId: string | null }>
47+
> {
4648
return record("uptime.lookup_schedule", async () => {
4749
try {
50+
console.log(`Looking up schedule with ID: ${id}`);
51+
4852
const schedule = await db.query.uptimeSchedules.findFirst({
4953
where: eq(uptimeSchedules.id, id),
5054
});
5155

5256
if (!schedule) {
57+
console.error(`Schedule not found in database: ${id}`);
5358
return { success: false, error: `Schedule ${id} not found` };
5459
}
5560

61+
console.log("Schedule found:", {
62+
id: schedule.id,
63+
url: schedule.url,
64+
websiteId: schedule.websiteId,
65+
userId: schedule.userId,
66+
});
67+
68+
if (!schedule.url) {
69+
console.error(`Schedule ${id} has NULL url - needs migration`);
70+
return {
71+
success: false,
72+
error: `Schedule ${id} has invalid data (missing url)`,
73+
};
74+
}
75+
5676
return {
5777
success: true,
5878
data: {
@@ -322,7 +342,11 @@ function getProbeMetadata(): Promise<{ ip: string; region: string }> {
322342
// }
323343

324344
// simplified status calculation - just UP or DOWN based on current check
325-
function calculateStatus(isUp: boolean): { status: number; retries: number; streak: number } {
345+
function calculateStatus(isUp: boolean): {
346+
status: number;
347+
retries: number;
348+
streak: number;
349+
} {
326350
const { UP, DOWN } = MonitorStatus;
327351
return { status: isUp ? UP : DOWN, retries: 0, streak: 0 };
328352
}

0 commit comments

Comments
 (0)