From daed2643c26ccad10b9e1052d974eede4f69642d Mon Sep 17 00:00:00 2001 From: francisco-leal Date: Fri, 23 Feb 2024 18:53:53 +0000 Subject: [PATCH] allow resetting scores --- commands/reset_scores.ts | 15 +++++++++++++++ commands/sync_scores.ts | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 commands/reset_scores.ts diff --git a/commands/reset_scores.ts b/commands/reset_scores.ts new file mode 100644 index 0000000..aae6527 --- /dev/null +++ b/commands/reset_scores.ts @@ -0,0 +1,15 @@ +import { BaseCommand } from '@adonisjs/core/ace' +import type { CommandOptions } from '@adonisjs/core/types/ace' +import { User } from '#models/user' + +export default class ResetScores extends BaseCommand { + static commandName = 'reset:scores' + static description = '' + + static options: CommandOptions = {} + + async run() { + this.logger.info('Hello world from "ResetScores"') + await User.query().update({ score: 0 }) + } +} diff --git a/commands/sync_scores.ts b/commands/sync_scores.ts index a81223a..6e7a005 100644 --- a/commands/sync_scores.ts +++ b/commands/sync_scores.ts @@ -23,7 +23,7 @@ export default class SyncScores extends BaseCommand { score += cast.watches_count score += cast.quotes_count * 1.5 if (cast.content.includes('$DEGEN')) { - score = score * 1.2 + score = score * 1.05 } return score } @@ -64,7 +64,7 @@ export default class SyncScores extends BaseCommand { for (let user of users) { processedUsers += 1 const casts = await Cast.query().where('user_id', user.id).orderBy('id', 'desc').limit(500) - const castScore = this.calculateCastsScore(casts) * 25 + const castScore = this.calculateCastsScore(casts) * 10 const connectionScore = this.calculateConnectionScore(user.follower_count)