Skip to content

Commit

Permalink
feat: implement syncRepositories cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiichyCode committed Mar 12, 2024
1 parent e5192ae commit 6ede990
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/api/trigger/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import "@/jobs";
export const { POST, dynamic } = createAppRoute(client);

//uncomment this to set a higher max duration (it must be inside your plan limits). Full docs: https://vercel.com/docs/functions/serverless-functions/runtimes#max-duration
//export const maxDuration = 60;
//export const maxDuration = 60;
1 change: 1 addition & 0 deletions src/jobs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// export all your job files here

export * from "./examples";
export * from "./sync-repositories";
21 changes: 21 additions & 0 deletions src/jobs/sync-repositories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { cronTrigger } from "@trigger.dev/sdk";
import { client } from "@/trigger";
import repositoryService from "@/services/repository.service";

client.defineJob({
id: "sync-repositories-job",
name: "Sync Repositories Job",
version: "0.0.1",

trigger: cronTrigger({
cron: "30 02 * * *",
}),

run: async (payload, io, ctx) => {
await io.runTask("sync-repositories", async () => {
return repositoryService.syncRepositories();
});

await io.logger.info("✨ Sync Repositories Job");
},
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { useEffect, useState, useTransition } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { signOut } from "next-auth/react";
import { Form } from "@/components/ui/form";
import { dataSharingAgreementSchema } from "./data-sharing-agreement-schema";
import { DataSharingContent } from "@/modules/repositories/components/DataSharingContent";
Expand All @@ -17,9 +17,9 @@ import {
} from "@/components/ui/form";
import { updateAgreementAction } from "@/services/actions/upgrade-agreement";
import { useRepositoriesContext } from "@/modules/repositories/context/repositoriesContext";
import type * as z from "zod";
import { Button } from "@/components/ui/button";
import { signOut } from "next-auth/react";

import type * as z from "zod";

export const DataSharingAgreementForm = () => {
const { user } = useRepositoriesContext();
Expand Down

0 comments on commit 6ede990

Please sign in to comment.