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 34 by douglas, 2004-07-20T16:49:06-07:00 vs.
Revision 44 by douglas, 2004-08-15T23:40:19-07:00

# Line 6 | Line 6
6  
7   #include "Publisher.hpp"
8   #include "Rss.hpp"
9 + #include "Atom.hpp"
10  
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 <
20 <        // publish
21 <
22 <        while (true)
23 <        {
24 <                double next(api::GetWallTimerSeconds() + Hour(1)), now;
25 <
26 <                update();
27 <
28 <                do
29 <                {
30 <                        sleep(Minute(1));
31 <
32 <                        now = api::GetWallTimerSeconds();
33 <                }
34 <                while (now < next);
35 <        }
36 < }
37 <
38 < void Publisher::update()
39 < {
40 <        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)) + "'");
26 >        db->Execute("DELETE FROM messages WHERE stamp<'"
27 >                + ext::String(stamp - Day(30)) + "'");
28  
29 <        for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy != buddies.end(); ++buddy)
29 >        for (std::set<Buddy>::const_iterator buddy(buddies.begin());
30 >                buddy != buddies.end(); ++buddy)
31          {
32                  ext::Handle<dbi::ResultSet> messages(db->Execute("SELECT stamp, message FROM messages WHERE id='"
33                          + lexical_cast<ext::String>(buddy->getId()) + "'"));
# Line 55 | Line 37 | void Publisher::update()
37                          messages->GetString("stamp")));
38  
39                  Rss rss(*buddy, messages_, stamp);
40 +                Atom atom(*buddy, messages_, stamp);
41 +
42 +                cerr << bright << yellow << "Updated feeds for " << blue << *buddy
43 +                        << yellow << ".\n" << reset;
44          }
45 +
46 +        cerr << bright << yellow << "Finished updating feeds at " << Stamp()
47 +                << ".\n" << reset;
48   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines