link to release; airtimes on artist and release

This commit is contained in:
dreamer 2020-10-15 21:41:22 +02:00
parent e1ed8cda9a
commit b9d7f1ac03
4 changed files with 19 additions and 12 deletions

View File

@ -29,4 +29,8 @@ app:match("artist", "/artist/:artist", json_params(function(self)
return handlers.Artisthandler(self)
end))
app:match("release", "/release/:release", json_params(function(self)
return handlers.Releasehandler(self)
end))
return app

View File

@ -12,6 +12,7 @@ local function Artisthandler(self)
local artist = models.Artists:find({ id = artist_id })
if not artist then
self:write({"Not Found", status = 404})
return
end
local hidden_fields = {
@ -25,7 +26,7 @@ local function Artisthandler(self)
end
local tracks = db.query([[
SELECT track.name AS track_name, release.name AS release_name
SELECT track.name AS track_name, track.id, release.name AS release_name
FROM track_artists
INNER JOIN
tracks AS track ON (track_artists.track = track.id)
@ -36,19 +37,20 @@ local function Artisthandler(self)
WHERE track_artists.artist = ?
]], artist["id"])
artist["tracks"] = tracks
-- local airtimes = db.query([[
-- SELECT airtime
-- FROM airtimes
-- WHERE track = ?
-- ]], track["id"])
for i, track in ipairs(tracks) do
local airtimes = db.query([[
SELECT airtime
FROM airtimes
WHERE track = ?
]], track["id"])
-- artist["airtimes"] = {}
-- for i, airtime in ipairs(airtimes) do
-- artist["airtimes"][i] = airtime.airtime
-- end
artist["tracks"][i]["airtimes"] = {}
for j, airtime in ipairs(airtimes) do
table.insert(artist["tracks"][i]["airtimes"], airtime['airtime'])
end
end
return { json = artist }

View File

@ -12,6 +12,7 @@ local function Trackhandler(self)
local track = models.Tracks:find({ id = track_id })
if not track then
self:write({"Not Found", status = 404})
return
end
local hidden_fields = {

View File

@ -20,7 +20,7 @@
</h5>
<p>
<span style="padding-right:5px;color:#fff;">
<% if item.release then %><%= item.release %><% end %>
<% if item.release then %><a href="<%= url_for("release")..item.release_id %>" style="color: #ffffff; text-decoration: none;"><%= item.release %></a><% end %>
<% if item.label then %>| <%= item.label %><% end %>
<% if item.year then %>| <%= item.year %><% end %>
<% if item.country then %>| <%= item.country %><% end %>