diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-01-06 22:28:41 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-01-06 22:28:41 (GMT) |
commit | a3f63b0b6fdcc8518f81695e6c2e6b643a50070a (patch) | |
tree | 0c51e30071770faa0a4be555ba0082c517755d3d /src | |
parent | 10bc85138c06e70ffb0507c57daee6a1637c3063 (diff) |
fix last_carts handling
Diffstat (limited to 'src')
-rw-r--r-- | src/playlog.lua | 6 | ||||
-rw-r--r-- | src/qlistener.lua | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/playlog.lua b/src/playlog.lua index 591468f..2bfc1af 100644 --- a/src/playlog.lua +++ b/src/playlog.lua @@ -64,7 +64,7 @@ function playlog:getLastCart(output, timestamp) local cart = cur:fetch() if cart == nil then cart = 0 end - return cart + return tonumber(cart) end function playlog:getLastCarts() @@ -79,11 +79,11 @@ function playlog:getLastCarts() data = cur:fetch(data, "a") if data == nil then break end - t[data.output] = self:getLastCart(data.output, data.timestamp) + carts[data.output] = self:getLastCart(data.output, data.timestamp) end cur:close() - return t + return carts end function playlog:insertNow(timestamp, cart, len, showtitle, title, artist, album, carttype, output) diff --git a/src/qlistener.lua b/src/qlistener.lua index 5e31890..ef3f6bb 100644 --- a/src/qlistener.lua +++ b/src/qlistener.lua @@ -35,7 +35,7 @@ function init(conffile) cnf = conf.load(conffile) end -function handle_now(timestamp, nowcart, nowlen) +function handle_now(timestamp, output, nowcart, nowlen) local results, err = rddb:getCartInfo(nowcart) if results == nil then io.stderr:write("ERROR: can't fetch cart info: " .. err .. "\n") @@ -46,7 +46,7 @@ function handle_now(timestamp, nowcart, nowlen) io.stderr:write("ERROR: can't fetch show/pool name: " .. carttype .. "\n") return true else - local ret, err = playlog:insertNow(timestamp, nowcart, nowlen, showtitle, results.TITLE, results.ARTIST, results.ALBUM, carttype) + local ret, err = playlog:insertNow(timestamp, nowcart, nowlen, showtitle, results.TITLE, results.ARTIST, results.ALBUM, carttype, output) if ret == nil then io.stderr:write("ERROR: can't insert cart info: " .. err .. "\n") else @@ -68,7 +68,7 @@ function handle_message(msg, q) if last_carts[output] == nil then last_carts[output] = 0 end if last_carts[output] ~= nowcart and nowlen > 0 then last_carts[output] = nowcart - local ret = handle_now(timestamp, nowcart, nowlen) + local ret = handle_now(timestamp, output, nowcart, nowlen) if ret == nil then io.stderr:write("INFO: trying to push last message back onto the queue - before exiting\n") local result, err = mq.send(q, timestamp .. " " .. output .. " " .. nowcart .. " " .. nowlen .. " " .. nextcart .. " " .. nextlen, 0) |