Skip to content

Commit

Permalink
feat: add cleanEmptyScores cron
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jun 27, 2024
1 parent 9804a72 commit 7d95c3b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions apps/api/src/cron/cleanEmptyScores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logger from '@hey/helpers/logger';
import prisma from 'src/helpers/prisma';

const cleanEmptyScores = async () => {
if (process.env.NEXT_PUBLIC_LENS_NETWORK !== 'mainnet') {
return;
}

await prisma.cachedProfileScore.deleteMany({
where: { score: 0 }
});
logger.info('Cron: cleanEmptyScores - Cleaned up empty scores');
};

export default cleanEmptyScores;
6 changes: 6 additions & 0 deletions apps/api/src/cron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cron from 'node-cron';
import cleanClickhouse from './cleanClickhouse';
import cleanDraftPublications from './cleanDraftPublications';
import cleanEmailTokens from './cleanEmailTokens';
import cleanEmptyScores from './cleanEmptyScores';
import cleanPreferences from './cleanPreferences';
import deleteLensPublications from './deleteLensPublications';
import heartbeat from './heartbeat';
Expand Down Expand Up @@ -55,6 +56,11 @@ const main = () => {
await cleanPreferences();
return;
});

cron.schedule('*/5 * * * *', async () => {
await cleanEmptyScores();
return;
});
};

main();
6 changes: 3 additions & 3 deletions apps/api/src/script/sync-score-to-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import axios from 'axios';
import lensPg from '../db/lensPg';

const baseUrl = 'https://api.hey.xyz/score/get';
const batchSize = 10;
const limit = 100000;
const offset = 34395;
const batchSize = 5;
const limit = 10000;
const offset = 89258;

const getProfiles = async () => {
const profiles = await lensPg.query(
Expand Down

0 comments on commit 7d95c3b

Please sign in to comment.