--- trunk/Publisher.cpp 2004/07/22 03:43:31 35 +++ trunk/Publisher.cpp 2004/08/16 04:33:25 43 @@ -11,45 +11,22 @@ 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) - { -// Stamp stamp; -// double next(api::GetWallTimerSeconds() + Hour(1)), now; - - update(); - -// cerr << stamp << '\n'; - -// 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)) + "'"); - 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()) + "'")); @@ -60,5 +37,11 @@ void Publisher::update() 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; }