comparison mod_pubsub_feeds/mod_pubsub_feeds.lua @ 2379:bc6e63ab2a7c

mod_pubsub_feeds: Iterate over feed backwards due to most feeds being in reverse chronological order
author Kim Alvefur <zash@zash.se>
date Sat, 19 Nov 2016 19:07:00 +0100
parents 02532f28b207
children 2f083426fe98
comparison
equal deleted inserted replaced
2378:649f733aa3dc 2379:bc6e63ab2a7c
77 77
78 function update_entry(item) 78 function update_entry(item)
79 local node = item.node; 79 local node = item.node;
80 module:log("debug", "parsing %d bytes of data in node %s", #item.data or 0, node) 80 module:log("debug", "parsing %d bytes of data in node %s", #item.data or 0, node)
81 local feed = parse_feed(item.data); 81 local feed = parse_feed(item.data);
82 local entries = {};
82 for entry in feed:childtags("entry") do 83 for entry in feed:childtags("entry") do
84 table.insert(entries, entry);
85 end
86 for i = #entries, 1, -1 do -- Feeds are usually in reverse order
87 local entry = feed[i];
83 entry.attr.xmlns = xmlns_atom; 88 entry.attr.xmlns = xmlns_atom;
84 89
85 local e_published = entry:get_child_text("published"); 90 local e_published = entry:get_child_text("published");
86 e_published = e_published and dt_parse(e_published); 91 e_published = e_published and dt_parse(e_published);
87 local e_updated = entry:get_child_text("updated"); 92 local e_updated = entry:get_child_text("updated");