Skip to content
Browse files

wip: tracks:update

  • Loading branch information...
1 parent 4db9f34 commit 636065e3a3c14342c63607545c3de301bf75a23a @comotion committed Nov 21, 2012
Showing with 35 additions and 22 deletions.
  1. +9 −4 TODO
  2. +1 −1 web/hangover.lua
  3. +1 −1 web/lib/lamt
  4. +16 −2 web/lib/tokyo.lua
  5. +8 −14 web/lib/tracks.lua
View
13 TODO
@@ -2,18 +2,23 @@
What to do and how:
+ file upload fucks up!:: b/c tracks_path doesnt exist
-+ empty searches?! :: b/c lua evals 0 to true!
-+ getracks 01.fuck you.
++ empty searches?! :: b/c lua evals 0 to true + fields is empty
++ getracks 01.fuck up.
+ empty upload fucks up
+ get nonexistant track fucks up
+
wishlist:
- - edit page :: WIP.. iterate over fields
+ - edit page :: WIP..
+ . iterate over fields
+ . hide some fields
+ . search -> edit button
- edit page adds tags
- error messages
- (add to .. ) playlist builder
- create program dialog (with sched picker)
- - delete track/playlist track/playlist/
+ - show schedule
+ - delete track/playlist{track}/playlist/program/
- get_next:
knows about silences, metadata, can queue songs
View
2 web/hangover.lua
@@ -141,7 +141,7 @@ end
-- Update
function put_db(web,...)
local id = ...
- local input = web.input.post_data
+ local input = web.POST
u.out(input)
if not input then
return json.encode{{result=nil, error="nothing to put"}}
2 web/lib/lamt
@@ -1 +1 @@
-Subproject commit 1c6f6e3539d45d5064a62cf153579492bcdccff7
+Subproject commit 6a27728f467734415db8017ae5b2e43a00da09d4
View
18 web/lib/tokyo.lua
@@ -1,4 +1,9 @@
-- goal is to abstract away db calls here
+--
+-- foo:init
+-- foo:put* key, val)
+-- foo:get(key)
+--
require "tokyocabinet"
require "os"
@@ -29,15 +34,24 @@ function tokyo:init(name)
return db
end
-function tokyo.put(db, pkey, cols)
+function tokyo:put(db, pkey, cols)
if not db:put(pkey, cols) then
- ecode = trk:ecode()
+ ecode = db:ecode()
return nil,nil,db:errmsg(ecode)
else
return pkey, cols
end
end
+function tokyo:search(db, query, qop, order)
+ local q = tokyocabinet.tdbqrynew(db)
+ for k,v in pairs(query) do
+ q:addcond(k, qop, v)
+ end
+ if order then q:setorder(unpack(order)) end
+ return q:search()
+end
+
-- create table mapping to magic constants
-- run only once plz
function tokyo_booter()
View
22 web/lib/tracks.lua
@@ -26,13 +26,13 @@ local u = require "lib/util"
module("tracks", package.seeall)
function tracks:init()
- return tokyo:init("tracks")
+ return db:init("tracks")
end
local trk = tracks:init()
function tracks:put(pkey,cols)
- return tokyo.put(trk, pkey, cols)
+ return db:put(trk, pkey, cols)
end
-- can have table of tags
@@ -50,22 +50,15 @@ function tracks:add(cols)
return id
end
end
- id = tracks:put(pkey, cols)
- print("the id added wasy: "..id)
- return id
+ return tracks:put(pkey, cols)
end
-- the simple search
function tracks:ssearch(query, qop, order)
local query = query or {station=default_station}
local qop = qop or db.op.equal
- q = tokyocabinet.tdbqrynew(trk)
- for k,v in pairs(query) do
- q:addcond(k, qop, v)
- end
- if order then q:setorder(unpack(order)) end
- local res = q:search()
-- q:setlimit(limit, skip) -- we need the size so there is no use
+ local res = db:search(trk, query, qop, order)
return res, #res
end
@@ -176,11 +169,12 @@ end
function tracks:update(pkey, cols)
p = tracks:get(pkey)
- for k,v in pairs(p) do
- cols[k] = v
+ -- merge teh data
+ for k,v in pairs(cols) do
+ p[k] = v
end
cols.updated = os.time()
- return tracks:put(pkey,cols)
+ return tracks:put(pkey, p)
end
-- return result with only fields

0 comments on commit 636065e

Please sign in to comment.
Something went wrong with that request. Please try again.