1
0

max_listeners -> peak_listeners.

This commit is contained in:
Alexander Andreev 2024-05-11 05:05:27 +04:00
parent 904af3107a
commit 056f2c022b
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
6 changed files with 10 additions and 10 deletions

View File

@ -28,7 +28,7 @@ func (s *Song) MarshalJSON() ([]byte, error) {
Title string `json:"title"` Title string `json:"title"`
DurationMill int64 `json:"duration_msec,omitempty"` DurationMill int64 `json:"duration_msec,omitempty"`
Listeners int64 `json:"listeners"` Listeners int64 `json:"listeners"`
PeakListeners int64 `json:"max_listeners"` PeakListeners int64 `json:"peak_listeners"`
StartAt string `json:"start_at"` StartAt string `json:"start_at"`
}{ }{
Artist: s.Artist, Artist: s.Artist,

View File

@ -1,3 +1,3 @@
INSERT OR IGNORE INTO `history` INSERT OR IGNORE INTO `history`
(`start_at`, `song_id`, `listeners`, `max_listeners`) (`start_at`, `song_id`, `listeners`, `peak_listeners`)
VALUES (?,?,?,?); VALUES (?,?,?,?);

View File

@ -3,14 +3,14 @@ SELECT
`artist`, `artist`,
`title`, `title`,
`listeners`, `listeners`,
`max_listeners` `peak_listeners`
FROM FROM
(SELECT (SELECT
`start_at`, `start_at`,
`artist`, `artist`,
`title`, `title`,
`listeners`, `listeners`,
`max_listeners` `peak_listeners`
FROM `history` FROM `history`
LEFT JOIN `song` LEFT JOIN `song`
ON `song`.`song_id` = `history`.`song_id` ON `song`.`song_id` = `history`.`song_id`

View File

@ -2,7 +2,7 @@ SELECT
MAX(`start_at`) AS `start_at`, MAX(`start_at`) AS `start_at`,
`artist`, `artist`,
`title`, `title`,
MAX(`max_listeners`) AS `max_listeners` MAX(`peak_listeners`) AS `peak_listeners`
FROM `history` FROM `history`
LEFT JOIN `song` LEFT JOIN `song`
ON `song`.`song_id` = `history`.`song_id`; ON `song`.`song_id` = `history`.`song_id`;

View File

@ -6,10 +6,10 @@ CREATE TABLE IF NOT EXISTS `song` (
UNIQUE (`artist`, `title`) ); UNIQUE (`artist`, `title`) );
CREATE TABLE IF NOT EXISTS `history` ( CREATE TABLE IF NOT EXISTS `history` (
`start_at` TEXT NOT NULL DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')), `start_at` TEXT NOT NULL DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),
`song_id` INTEGER NOT NULL, `song_id` INTEGER NOT NULL,
`listeners` INTEGER NOT NULL, `listeners` INTEGER NOT NULL,
`max_listeners` INTEGER NOT NULL, `peak_listeners` INTEGER NOT NULL,
PRIMARY KEY (`start_at`), PRIMARY KEY (`start_at`),
FOREIGN KEY (`song_id`) REFERENCES `song` (`song_id`) FOREIGN KEY (`song_id`) REFERENCES `song` (`song_id`)
ON UPDATE CASCADE ON DELETE CASCADE ); ON UPDATE CASCADE ON DELETE CASCADE );

View File

@ -27,7 +27,7 @@ async function updateStatus() {
for (let i = 0; i < s.last_songs.length; ++i) { for (let i = 0; i < s.last_songs.length; ++i) {
let row = $("last-songs").lastChild.insertRow(); let row = $("last-songs").lastChild.insertRow();
row.insertCell().appendChild(document.createTextNode(formatStartAt(new Date(s.last_songs[i].start_at)))); row.insertCell().appendChild(document.createTextNode(formatStartAt(new Date(s.last_songs[i].start_at))));
row.insertCell().appendChild(document.createTextNode((s.last_songs[i].listeners == 0 ? "" : s.last_songs[i].listeners + "/") + (s.last_songs[i].max_listeners == 0 ? "" : s.last_songs[i].max_listeners))); row.insertCell().appendChild(document.createTextNode((s.last_songs[i].listeners == 0 ? "" : s.last_songs[i].listeners + "/") + (s.last_songs[i].peak_listeners == 0 ? "" : s.last_songs[i].peak_listeners)));
row.insertCell().appendChild(document.createTextNode(`${s.last_songs[i].artist} - ${s.last_songs[i].title}`)); row.insertCell().appendChild(document.createTextNode(`${s.last_songs[i].artist} - ${s.last_songs[i].title}`));
} }
} }