Add tag list
This commit is contained in:
parent
4744a22ef6
commit
c4e67c119e
3 changed files with 18 additions and 3 deletions
16
pug/tag_list.pug
Normal file
16
pug/tag_list.pug
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
extends includes/layout.pug
|
||||||
|
|
||||||
|
block view
|
||||||
|
.mx-auto.w100.wmx11.fs-body1#content
|
||||||
|
.s-table-container
|
||||||
|
table.s-table.s-table__bx
|
||||||
|
thead
|
||||||
|
th Tag
|
||||||
|
th Labels
|
||||||
|
th Albums
|
||||||
|
tbody
|
||||||
|
each item in items
|
||||||
|
tr
|
||||||
|
td= item.tag
|
||||||
|
td= item.labels
|
||||||
|
td= item.albums
|
|
@ -29,6 +29,7 @@ const sqls = {
|
||||||
label_grid: "SELECT iif(count(DISTINCT band_name) = 1, band_name, band_url) AS display_name, band_url, count(DISTINCT item_id) AS album_count, count(DISTINCT band_name) AS artist_count, count(*) AS track_count, iif(sum(duration) > 3600, cast(total(duration)/3600 AS INTEGER) || 'h ' || cast(total(duration)/60%60 AS INTEGER) || 'm', cast(total(duration)/60 AS INTEGER) || 'm') AS total_duration FROM item INNER JOIN track USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} GROUP BY band_url ORDER BY display_name COLLATE NOCASE",
|
label_grid: "SELECT iif(count(DISTINCT band_name) = 1, band_name, band_url) AS display_name, band_url, count(DISTINCT item_id) AS album_count, count(DISTINCT band_name) AS artist_count, count(*) AS track_count, iif(sum(duration) > 3600, cast(total(duration)/3600 AS INTEGER) || 'h ' || cast(total(duration)/60%60 AS INTEGER) || 'm', cast(total(duration)/60 AS INTEGER) || 'm') AS total_duration FROM item INNER JOIN track USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} GROUP BY band_url ORDER BY display_name COLLATE NOCASE",
|
||||||
label_list: "SELECT iif(count(DISTINCT band_name) = 1, band_name, band_url) AS display_name, band_url, count(DISTINCT item_id) AS album_count, count(DISTINCT band_name) AS artist_count, count(*) AS track_count, iif(sum(duration) > 3600, cast(total(duration)/3600 AS INTEGER) || 'h ' || cast(total(duration)/60%60 AS INTEGER) || 'm', cast(total(duration)/60 AS INTEGER) || 'm') AS total_duration FROM item INNER JOIN track USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} GROUP BY band_url ORDER BY display_name COLLATE NOCASE",
|
label_list: "SELECT iif(count(DISTINCT band_name) = 1, band_name, band_url) AS display_name, band_url, count(DISTINCT item_id) AS album_count, count(DISTINCT band_name) AS artist_count, count(*) AS track_count, iif(sum(duration) > 3600, cast(total(duration)/3600 AS INTEGER) || 'h ' || cast(total(duration)/60%60 AS INTEGER) || 'm', cast(total(duration)/60 AS INTEGER) || 'm') AS total_duration FROM item INNER JOIN track USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} GROUP BY band_url ORDER BY display_name COLLATE NOCASE",
|
||||||
tag_grid: "SELECT tag, count(*) AS count FROM item_tag INNER JOIN item USING (account, item_id) WHERE account = ? {WHERE} GROUP BY tag, band_url ORDER BY count DESC",
|
tag_grid: "SELECT tag, count(*) AS count FROM item_tag INNER JOIN item USING (account, item_id) WHERE account = ? {WHERE} GROUP BY tag, band_url ORDER BY count DESC",
|
||||||
|
tag_list: "SELECT tag, count(*) AS labels, sum(count) AS albums FROM (SELECT tag, count(*) AS count FROM item_tag INNER JOIN item USING (account, item_id) WHERE account = ? {WHERE} GROUP BY tag, band_url) GROUP BY tag ORDER BY labels DESC",
|
||||||
track_list: "SELECT * FROM track INNER JOIN item USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} ORDER BY band_url, item_title COLLATE NOCASE, track_number"
|
track_list: "SELECT * FROM track INNER JOIN item USING (account, item_id) {JOIN TAG} WHERE account = ? {WHERE} ORDER BY band_url, item_title COLLATE NOCASE, track_number"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ router.get("/:account/", defineEventHandler({
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const prepared = db.prepare(sql)
|
const prepared = db.prepare(sql)
|
||||||
if (arrange === "tag") {
|
if (mode === "tag_grid") {
|
||||||
prepared.raw()
|
prepared.raw()
|
||||||
}
|
}
|
||||||
var items = prepared.all(params)
|
var items = prepared.all(params)
|
||||||
|
|
|
@ -55,7 +55,6 @@ const downloadManager = new class {
|
||||||
return this.inProgressTagDownloads.get(account) || (() => {
|
return this.inProgressTagDownloads.get(account) || (() => {
|
||||||
const downloader = new TagDownloader(account)
|
const downloader = new TagDownloader(account)
|
||||||
this.inProgressTagDownloads.set(account, downloader)
|
this.inProgressTagDownloads.set(account, downloader)
|
||||||
console.log(`created downloader ${account}`)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.resolve(account)
|
this.resolve(account)
|
||||||
})
|
})
|
||||||
|
@ -74,7 +73,6 @@ const downloadManager = new class {
|
||||||
resolve(account) {
|
resolve(account) {
|
||||||
const downloader = this.check(account)
|
const downloader = this.check(account)
|
||||||
if (!downloader.running) {
|
if (!downloader.running) {
|
||||||
console.log(`disposed downloader ${account}`)
|
|
||||||
this.inProgressTagDownloads.delete(account)
|
this.inProgressTagDownloads.delete(account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue