Skip to content

Commit 1be303b

Browse files
committed
Account for downloads happening while updating counts
Only set the `counted` row to precisely the amount that we actually updated.
1 parent 04d1068 commit 1be303b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bin/update-downloads.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ fn collect(tx: &postgres::Transaction,
121121
// Flag this row as having been processed if we're passed the cutoff,
122122
// and unconditionally increment the number of counted downloads.
123123
try!(tx.execute("UPDATE version_downloads
124-
SET processed = $2, counted = downloads
124+
SET processed = $2, counted = counted + $3
125125
WHERE id = $1",
126-
&[id, &(download.date < cutoff)]));
126+
&[id, &(download.date < cutoff), &amt]));
127127
total += amt as i64;
128128
}
129129

0 commit comments

Comments
 (0)