link to release; airtimes on artist and release
This commit is contained in:
@@ -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 }
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user