ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Publisher.cpp
(Generate patch)

Comparing trunk/Publisher.cpp (file contents):
Revision 35 by douglas, 2004-07-21T20:43:31-07:00 vs.
Revision 43 by douglas, 2004-08-15T21:33:25-07:00

# Line 11 | Line 11
11   Publisher::Publisher(const std::set<Buddy>& buddies, const Database& database, bool start) : buddies(buddies),
12          database(database), start(start)
13   {
14 <        if (start) publisher.Spawn(etl::Bind<0>(&Publisher::publish, this));
14 >        if (start) publish();
15   }
16  
17 < int Publisher::publish()
17 > void Publisher::publish()
18   {
19 <        cerr << bright << green << "Publisher::publish()\n" << reset;
20 <
21 <        // publish
22 <
23 < //      while (true)
24 <        {
25 < //              Stamp stamp;
26 < //              double next(api::GetWallTimerSeconds() + Hour(1)), now;
27 <
28 <                update();
29 <
30 < //              cerr << stamp << '\n';
31 <
32 < //              do
33 <                {
34 < //                      sleep(Minute(1));
35 <
36 < //                      now = api::GetWallTimerSeconds();
37 <                }
38 < //              while (now < next);
39 <        }
40 < }
41 <
42 < void Publisher::update()
43 < {
44 <        cerr << bright << yellow << "Publisher::update()\n" << reset;
19 >        cerr << bright << yellow << "Started updating feeds at " << Stamp()
20 >                << ".\n" << reset;
21  
22          Stamp stamp;
23 <        ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host, database.user, database.password,
24 <                database.db));
23 >        ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host,
24 >                database.user, database.password, database.db));
25  
26          db->Execute("DELETE FROM messages WHERE stamp<'" + ext::String(stamp - Day(30)) + "'");
27  
28 <        for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy != buddies.end(); ++buddy)
28 >        for (std::set<Buddy>::const_iterator buddy(buddies.begin());
29 >                buddy != buddies.end(); ++buddy)
30          {
31                  ext::Handle<dbi::ResultSet> messages(db->Execute("SELECT stamp, message FROM messages WHERE id='"
32                          + lexical_cast<ext::String>(buddy->getId()) + "'"));
# Line 60 | Line 37 | void Publisher::update()
37  
38                  Rss rss(*buddy, messages_, stamp);
39                  Atom atom(*buddy, messages_, stamp);
40 +
41 +                cerr << bright << yellow << "Updated feeds for " << blue << *buddy
42 +                        << yellow << ".\n" << reset;
43          }
44 +
45 +        cerr << bright << yellow << "Finished updating feeds at " << Stamp()
46 +                << ".\n" << reset;
47   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines