fix: use new cron software

This commit is contained in:
Saahil 2025-01-07 13:48:12 -05:00
parent 4c8cdb8fc5
commit 144cedbaf8
No known key found for this signature in database
GPG key ID: 8A8B64515254CFC6
3 changed files with 13 additions and 1 deletions

View file

@ -15,6 +15,7 @@
"body-parser": "latest",
"cheerio": "latest",
"cors": "latest",
"croner": "^9.0.0",
"dotenv": "^16.4.5",
"eventsource": "latest",
"form-data": "^4.0.1",

View file

@ -1,5 +1,6 @@
import { ModifiedApp } from "./slackapp";
import cron from "node-cron";
import { Cron } from "croner";
export interface AirtableResponse {
id: string;
createdTime: string;
@ -298,6 +299,10 @@ export async function fetchPerson() {
}
export function highSeasCron(app: ModifiedApp) {
app.client.chat.postMessage({
channel: `C07LGLUTNH2`,
text: `:clock: High Seas cron started`,
})
cron.schedule(`*/2 * * * *`, async () => {
try {
await fetch("https://highseas.hackclub.com/shipyard", {
@ -337,7 +342,7 @@ export function highSeasCron(app: ModifiedApp) {
// await cronForAirtable(app);
// });
cron.schedule("*/10 * * * *", async () => {
const job = new Cron("*/10 * * * *", async () => {
try {
// update da cache
const oldInstance = app.db.get(`highseas_lb`) || [];
@ -413,6 +418,7 @@ export function highSeasCron(app: ModifiedApp) {
});
}
});
return { job }
}
export async function getLb() {

View file

@ -1645,6 +1645,11 @@ create-require@^1.1.0:
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
croner@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/croner/-/croner-9.0.0.tgz#1db62160142cf32eb22622e9ae27ba29156883f7"
integrity sha512-onMB0OkDjkXunhdW9htFjEhqrD54+M94i6ackoUkjHKbRnXdyEyKRelp4nJ1kAz32+s27jP1FsebpJCVl0BsvA==
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"