Skip to content

Commit

Permalink
ci: apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jan 13, 2025
1 parent fdf3096 commit e2a30d5
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions apps/workflows/src/cron/monitor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { google } from "@google-cloud/tasks/build/protos/protos";
import type { google } from "@google-cloud/tasks/build/protos/protos";
import { and, db, eq, isNull, lte, max, ne, or, schema } from "@openstatus/db";
import { user } from "@openstatus/db/src/schema";

import { Redis } from "@openstatus/upstash";
import { env } from "../env";
import { CloudTasksClient } from "@google-cloud/tasks";
import { Redis } from "@openstatus/upstash";
import { z } from "zod";
import { env } from "../env";

const redis = Redis.fromEnv();

Expand Down Expand Up @@ -75,7 +75,7 @@ export async function LaunchMonitorWorkflow() {
await CreateTask({
parent,
client: client,
"step": "14days",
step: "14days",
});
// if they have check if the user is in the workflow
// If user not in workflow
Expand Down Expand Up @@ -103,13 +103,14 @@ export async function StepPaused() {
// pause monitors
}

async function hasUserLoggedIn(
{ userId, date }: { userId: number; date: Date },
) {
const userResult = await db.select({ lastConnection: schema.user.updatedAt })
.from(
schema.user,
).where(eq(schema.user.id, userId));
async function hasUserLoggedIn({
userId,
date,
}: { userId: number; date: Date }) {
const userResult = await db
.select({ lastConnection: schema.user.updatedAt })
.from(schema.user)
.where(eq(schema.user.id, userId));

if (userResult.length === 0) {
console.error("Something strange no user found", userId);
Expand All @@ -121,13 +122,15 @@ async function hasUserLoggedIn(
return user.lastConnection > date;
}

function CreateTask(
{ parent, client, step }: {
parent: string;
client: CloudTasksClient;
step: z.infer<typeof workflowStepSchema>;
},
) {
function CreateTask({
parent,
client,
step,
}: {
parent: string;
client: CloudTasksClient;
step: z.infer<typeof workflowStepSchema>;
}) {
const url = "";
const timestamp = Date.now();
const payload = {}; // Should we send some data to the task or only in the url/
Expand Down

0 comments on commit e2a30d5

Please sign in to comment.