Skip to content

Commit

Permalink
Fix ppv1 background threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Apr 3, 2024
1 parent 32495af commit 5a5a1a1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions helpers/performance/ppv1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from __future__ import annotations

from ...database.repositories import scores, wrapper
from ...database.repositories import scores, beatmaps, wrapper
from ...database.objects import DBScore, DBBeatmap
from ...constants import Mods

Expand All @@ -22,20 +22,25 @@ def calculate_star_rating(beatmap: DBBeatmap) -> float:

def calculate_ppv1(score: DBScore, session: Session) -> float:
"""Calculate ppv1, by using the score's pp as a difficulty factor"""
if score.beatmap.playcount <= 0:
beatmap = beatmaps.fetch_by_id(
score.beatmap_id,
session=session
)

if beatmap.playcount <= 0:
return 0

score_rank = scores.fetch_score_index_by_tscore(
score.total_score,
score.beatmap.id,
beatmap.id,
score.mode,
session=session
)

mods = Mods(score.mods)

# TODO: Use old eyup star rating
star_rating = calculate_star_rating(score.beatmap)
star_rating = calculate_star_rating(beatmap)

base_pp = math.pow(star_rating, 4) / math.pow(score_rank, 0.5)

Expand All @@ -54,15 +59,15 @@ def calculate_ppv1(score: DBScore, session: Session) -> float:
ez_nerf = 0.2 if (Mods.Easy in mods) or (Mods.HalfTime in mods) else 1

# NOTE: Beatmap popularity is nefed a LOT, since it would inflate pp to the roof
populariy_factor = math.pow(score.beatmap.playcount, 0.145)
populariy_factor = math.pow(beatmap.playcount, 0.145)
acc_factor = math.pow(score.acc, 15)

# Nerf converts
if score.mode > 0 and score.mode != score.beatmap.mode:
if score.mode > 0 and score.mode != beatmap.mode:
base_pp *= 0.2

# Nerf "easy maps"... idk?
if score.mode != 1 and (score.beatmap.passcount / score.beatmap.playcount) > 0.3:
if score.mode != 1 and (beatmap.passcount / beatmap.playcount) > 0.3:
base_pp *= 0.2

result_pp = math.prod([
Expand Down

0 comments on commit 5a5a1a1

Please sign in to comment.