Add comments and tweak formatting

This commit is contained in:
Alex Cabal 2025-05-23 10:51:19 -05:00
parent f6aef54767
commit 2122b0f625
2 changed files with 5 additions and 3 deletions

View file

@ -5,7 +5,9 @@ use Safe\DateTimeImmutable;
class EbookDownloadSummary{
public int $EbookId;
public DateTimeImmutable $Date;
/** The number of downloads by non-bot clients on the given date. */
public int $DownloadCount = 0;
/** The number of downloads by bot clients on the given date. */
public int $BotDownloadCount = 0;
public function __construct(int $ebookId, DateTimeImmutable $date){

View file

@ -35,9 +35,9 @@ foreach($downloadDates as $date){
Db::Query('
UPDATE Ebooks e
left join (
select EbookId, sum(DownloadCount) AS DownloadsPast30Days
select EbookId, sum(DownloadCount) as DownloadsPast30Days
from EbookDownloadSummaries
where Date >= curdate() - interval 29 day
where Date >= date(utc_timetamp()) - interval 30 day
group by EbookId
) s on e.EbookId = s.EbookId
set e.DownloadsPast30Days = coalesce(s.DownloadsPast30Days, 0)
@ -46,7 +46,7 @@ Db::Query('
Db::Query('
UPDATE Ebooks e
left join (
select EbookId, sum(DownloadCount) AS DownloadsTotal
select EbookId, sum(DownloadCount) as DownloadsTotal
from EbookDownloadSummaries
group by EbookId
) s on e.EbookId = s.EbookId