Skip to content

Commit 06e6ed0

Browse files
committed
fix: partial download recalculation won't work anymore
1 parent 757220f commit 06e6ed0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/jobs/download_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use sqlx::PgConnection;
33
pub async fn start(pool: &mut PgConnection) -> Result<(), String> {
44
// update mod_versions counts
55
if let Err(e) = sqlx::query!(
6-
"UPDATE mod_versions mv SET download_count = mv.download_count + (
6+
"UPDATE mod_versions mv SET download_count = (
77
SELECT COUNT(DISTINCT md.ip) FROM mod_downloads md
8-
WHERE md.mod_version_id = mv.id AND md.time_downloaded > mv.last_download_cache_refresh
8+
WHERE md.mod_version_id = mv.id
99
), last_download_cache_refresh = now()
1010
FROM mod_version_statuses mvs
1111
WHERE mv.status_id = mvs.id AND mvs.status = 'accepted'"

src/types/models/mod_version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,9 @@ impl ModVersion {
698698
) -> Result<(), ApiError> {
699699
if let Err(e) = sqlx::query!(
700700
"UPDATE mod_versions mv
701-
SET download_count = mv.download_count + (
701+
SET download_count = (
702702
SELECT COUNT(DISTINCT md.ip) FROM mod_downloads md
703-
WHERE md.mod_version_id = mv.id AND md.time_downloaded > mv.last_download_cache_refresh
703+
WHERE md.mod_version_id = mv.id
704704
), last_download_cache_refresh = now()
705705
FROM mod_version_statuses mvs
706706
WHERE mv.id = $1 AND mvs.mod_version_id = mv.id AND mvs.status = 'accepted'",

0 commit comments

Comments
 (0)