Skip to content

Commit

Permalink
added relevance settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Nov 23, 2024
1 parent 984ec4f commit 81c9f89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/workshop/bandage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { generate_response } from 'src/common/bandage_response';
const moderation_id = [4, 13]; // на проверке, отклонено
const official_id = 0;

// Relevance settings
const downgrade_factor = 1.5;
const start_boost = 1;

interface BandageSearch {
title?: { contains: string },
description?: { contains: string },
Expand Down Expand Up @@ -142,10 +146,10 @@ export class BandageService {
const count = await this.prisma.bandage.count({ where: where });

const getRelevance = (bandage: { stars: any[]; creationDate: Date; }) => {
const stars = bandage.stars.length;
const stars = bandage.stars.length + start_boost;
const daysSinceCreation =
(Date.now() - new Date(bandage.creationDate).getTime()) / (1000 * 60 * 60 * 24);
return stars / Math.pow(daysSinceCreation + 1, 1.5);
return stars / Math.pow(daysSinceCreation + 1, downgrade_factor);
}

const startIndex = page * take;
Expand Down

0 comments on commit 81c9f89

Please sign in to comment.