Skip to content

Commit 2d934d4

Browse files
committed
refactor: adjust trust action weights and simplify getTrustLevel logic
1 parent 67a8b70 commit 2d934d4

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/lib/trust/config.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { TrustAction } from '@orm'
33

44
export const TRUST_ACTIONS = {
55
[TrustAction.UPVOTE]: { weight: 1, description: 'Upvoted a listing' },
6-
[TrustAction.DOWNVOTE]: { weight: -1, description: 'Downvoted a listing' },
6+
[TrustAction.DOWNVOTE]: { weight: 1, description: 'Downvoted a listing' },
77
[TrustAction.LISTING_CREATED]: {
88
weight: 1,
99
description: 'Created a listing',
1010
},
1111
[TrustAction.LISTING_APPROVED]: {
12-
weight: 4,
12+
weight: 6,
1313
description: 'Listing was approved',
1414
},
1515
[TrustAction.LISTING_REJECTED]: {
@@ -72,9 +72,7 @@ export const TRUST_CONFIG = {
7272
export function getTrustLevel(score: number): TrustLevel {
7373
// Find the highest level the user qualifies for
7474
for (let i = TRUST_LEVELS.length - 1; i >= 0; i--) {
75-
if (score >= TRUST_LEVELS[i].minScore) {
76-
return TRUST_LEVELS[i]
77-
}
75+
if (score >= TRUST_LEVELS[i].minScore) return TRUST_LEVELS[i]
7876
}
7977
return TRUST_LEVELS[0] // Default to 'New' level
8078
}
@@ -85,11 +83,9 @@ export function getNextTrustLevel(currentScore: number): TrustLevel | null {
8583
(level) => level.name === currentLevel.name,
8684
)
8785

88-
if (currentIndex < TRUST_LEVELS.length - 1) {
89-
return TRUST_LEVELS[currentIndex + 1]
90-
}
91-
92-
return null // Already at max level
86+
return currentIndex < TRUST_LEVELS.length - 1
87+
? TRUST_LEVELS[currentIndex + 1]
88+
: null // Already at max level
9389
}
9490

9591
export function getProgressToNextLevel(currentScore: number): number {

0 commit comments

Comments
 (0)