--- trunk/Publisher.cpp 2004/07/20 23:49:06 34 +++ trunk/Publisher.cpp 2004/08/16 06:40:19 44 @@ -6,46 +6,28 @@ #include "Publisher.hpp" #include "Rss.hpp" +#include "Atom.hpp" Publisher::Publisher(const std::set& buddies, const Database& database, bool start) : buddies(buddies), database(database), start(start) { - if (start) publisher.Spawn(etl::Bind<0>(&Publisher::publish, this)); + if (start) publish(); } -int Publisher::publish() +void Publisher::publish() { - cerr << bright << green << "Publisher::publish()\n" << reset; - - // publish - - while (true) - { - double next(api::GetWallTimerSeconds() + Hour(1)), now; - - update(); - - do - { - sleep(Minute(1)); - - now = api::GetWallTimerSeconds(); - } - while (now < next); - } -} - -void Publisher::update() -{ - cerr << bright << yellow << "Publisher::update()\n" << reset; + cerr << bright << yellow << "Started updating feeds at " << Stamp() + << ".\n" << reset; Stamp stamp; - ext::Handle db(dbi::Connect(database.driver, database.host, database.user, database.password, - database.db)); + ext::Handle db(dbi::Connect(database.driver, database.host, + database.user, database.password, database.db)); - db->Execute("DELETE FROM messages WHERE stamp<'" + ext::String(stamp - Day(30)) + "'"); + db->Execute("DELETE FROM messages WHERE stamp<'" + + ext::String(stamp - Day(30)) + "'"); - for (std::set::const_iterator buddy(buddies.begin()); buddy != buddies.end(); ++buddy) + for (std::set::const_iterator buddy(buddies.begin()); + buddy != buddies.end(); ++buddy) { ext::Handle messages(db->Execute("SELECT stamp, message FROM messages WHERE id='" + lexical_cast(buddy->getId()) + "'")); @@ -55,5 +37,12 @@ void Publisher::update() messages->GetString("stamp"))); Rss rss(*buddy, messages_, stamp); + Atom atom(*buddy, messages_, stamp); + + cerr << bright << yellow << "Updated feeds for " << blue << *buddy + << yellow << ".\n" << reset; } + + cerr << bright << yellow << "Finished updating feeds at " << Stamp() + << ".\n" << reset; }