Mercurial > prosody-modules
comparison mod_archive/mod_archive.lua @ 224:96e29ff5fa07
mod_archive: keep collections in chronological order.
author | shinysky<shinysky1986(AT)gmail.com> |
---|---|
date | Mon, 26 Jul 2010 21:15:41 +0800 |
parents | de71a52fc63a |
children | 95d4d53f09a1 |
comparison
equal
deleted
inserted
replaced
223:de71a52fc63a | 224:96e29ff5fa07 |
---|---|
68 dm.list_store(node, host, ARCHIVE_DIR, st.preserialize(data)); | 68 dm.list_store(node, host, ARCHIVE_DIR, st.preserialize(data)); |
69 return; | 69 return; |
70 end | 70 end |
71 end | 71 end |
72 else -- if the last collection occurs on the same day, then join it | 72 else -- if the last collection occurs on the same day, then join it |
73 -- TODO assuming the collection list are in reverse chronological order | 73 -- TODO assuming the collection list are in chronological order |
74 local collection = st.deserialize(data[1]); | 74 local collection = st.deserialize(data[#data]); |
75 local difftime = os.difftime(date_parse(utc), date_parse(collection.attr["start"])); | 75 local difftime = os.difftime(date_parse(utc), date_parse(collection.attr["start"])); |
76 if difftime < 86400 then -- 60 * 60 * 24 | 76 if difftime < 86400 then -- 60 * 60 * 24 |
77 collection:tag(tag, {secs='1', utc=utc}):add_child(body); | 77 collection:tag(tag, {secs='1', utc=utc}):add_child(body); |
78 local ver = tonumber(collection.attr["version"]) + 1; | 78 local ver = tonumber(collection.attr["version"]) + 1; |
79 collection.attr["version"] = tostring(ver); | 79 collection.attr["version"] = tostring(ver); |
80 collection.attr["access"] = utc; | 80 collection.attr["access"] = utc; |
81 data[1] = collection; | 81 data[#data] = collection; |
82 dm.list_store(node, host, ARCHIVE_DIR, st.preserialize(data)); | 82 dm.list_store(node, host, ARCHIVE_DIR, st.preserialize(data)); |
83 return; | 83 return; |
84 end | 84 end |
85 end | 85 end |
86 end | 86 end |