Record and summarize Ebook downloads in the DB (#498)

This commit is contained in:
Mike Colagrosso 2025-05-22 10:23:24 -06:00 committed by GitHub
parent 61b8ca27b1
commit 475c437126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 289 additions and 4 deletions

View file

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS `EbookDownloadSummaries` (
`EbookId` int(10) unsigned NOT NULL,
`Date` date NOT NULL,
`DownloadCount` int(10) unsigned NOT NULL DEFAULT 0,
`BotDownloadCount` int(10) unsigned NOT NULL DEFAULT 0,
UNIQUE INDEX `idxUnique` (`EbookId`, `Date`),
INDEX `index1` (Date, EbookId, DownloadCount),
INDEX `index2` (EbookId, DownloadCount)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `EbookDownloads` (
`EbookId` int(10) unsigned NOT NULL,
`Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`IpAddress` inet6 NULL,
`UserAgent` mediumtext NULL,
INDEX `idxCreated` (`Created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -27,6 +27,8 @@ CREATE TABLE IF NOT EXISTS `Ebooks` (
`IndexableText` text NULL,
`IndexableAuthors` text NOT NULL,
`IndexableCollections` text NULL,
`DownloadsPast30Days` int(10) unsigned NOT NULL DEFAULT 0,
`DownloadsTotal` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`EbookId`),
UNIQUE KEY `index1` (`Identifier`),
KEY `index2` (`EbookCreated`),