mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 18:11:52 -04:00
Change DownloadCount to mean the total number of downloads including bot downloads
This commit is contained in:
parent
2122b0f625
commit
d268681f3c
3 changed files with 8 additions and 7 deletions
|
@ -19,12 +19,11 @@ foreach($downloadDates as $date){
|
|||
$summaries[$ebookId] = new EbookDownloadSummary($ebookId, $downloadDate);
|
||||
}
|
||||
|
||||
$summaries[$ebookId]->DownloadCount++;
|
||||
|
||||
if($ebookDownload->IsBot()){
|
||||
$summaries[$ebookId]->BotDownloadCount++;
|
||||
}
|
||||
else{
|
||||
$summaries[$ebookId]->DownloadCount++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($summaries as $summary){
|
||||
|
@ -35,9 +34,9 @@ foreach($downloadDates as $date){
|
|||
Db::Query('
|
||||
UPDATE Ebooks e
|
||||
left join (
|
||||
select EbookId, sum(DownloadCount) as DownloadsPast30Days
|
||||
select EbookId, sum(DownloadCount) - sum(BotDownloadCount) as DownloadsPast30Days
|
||||
from EbookDownloadSummaries
|
||||
where Date >= date(utc_timetamp()) - interval 30 day
|
||||
where Date >= date(utc_timestamp()) - interval 30 day
|
||||
group by EbookId
|
||||
) s on e.EbookId = s.EbookId
|
||||
set e.DownloadsPast30Days = coalesce(s.DownloadsPast30Days, 0)
|
||||
|
@ -46,7 +45,7 @@ Db::Query('
|
|||
Db::Query('
|
||||
UPDATE Ebooks e
|
||||
left join (
|
||||
select EbookId, sum(DownloadCount) as DownloadsTotal
|
||||
select EbookId, sum(DownloadCount) - sum(BotDownloadCount) as DownloadsTotal
|
||||
from EbookDownloadSummaries
|
||||
group by EbookId
|
||||
) s on e.EbookId = s.EbookId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue