liquid_feedback_frontend
diff app/main/timeline/index.lua @ 146:77260f05fd4b
implement advanced date searches
date-date in range
since: date
age: 10 timestamp
date-date in range
since: date
age: 10 timestamp
| author | Daniel Poelzleithner <poelzi@poelzi.org> |
|---|---|
| date | Thu Oct 07 03:34:19 2010 +0200 (2010-10-07) |
| parents | 90520c9fca44 |
| children | 165f4bd02cf3 |
line diff
1.1 --- a/app/main/timeline/index.lua Thu Oct 07 00:35:48 2010 +0200 1.2 +++ b/app/main/timeline/index.lua Thu Oct 07 03:34:19 2010 +0200 1.3 @@ -138,7 +138,7 @@ 1.4 } 1.5 1.6 ui.script{ static = "gregor.js/gregor.js" } 1.7 - util.gregor("timeline_search_date", "document.getElementById('timeline_search_date').form.submit();") 1.8 + util.gregor("timeline_search_date", true) 1.9 1.10 1.11 ui.link{ 1.12 @@ -337,7 +337,22 @@ 1.13 if date == "last_24h" then 1.14 tmp:add_where{ "occurrence > now() - '24 hours'::interval" } 1.15 else 1.16 - tmp:add_where{ "occurrence::date = ?::date", date } 1.17 + local start,stop = string.gmatch(date, "(%d+-%d+-%d+):(%d+-%d+-%d+)")() 1.18 + if start and stop then 1.19 + tmp:add_where{ "occurrence::date >= ?::date AND occurrence::date <= ?::date", start, stop } 1.20 + else 1.21 + local age = string.gmatch(date, "age:(.+)")() 1.22 + if age then 1.23 + tmp:add_where{ "occurrence >= now() - ?::interval", age } 1.24 + else 1.25 + local since = string.gmatch(date, "since:%s*(%d+-%d+-%d+)%s*")() 1.26 + if since then 1.27 + tmp:add_where{ "occurrence::date >= ?::date", since } 1.28 + else 1.29 + tmp:add_where{ "occurrence::date = ?::date", date } 1.30 + end 1.31 + end 1.32 + end 1.33 end 1.34 tmp 1.35 :left_join("draft", nil, "draft.id = timeline.draft_id")