self.data = data
+ def __cmp__(self, other):
+ return cmp(self.published, other.published)
+
@property
def id(self):
return self.data.id
self.db.execute("INSERT INTO planet_views(post_id, referer, location) \
VALUES(%s, %s, %s)", self.id, referer, location)
+ if hasattr(self, "_views"):
+ self._views += 1
+
+ @property
+ def views(self):
+ if not hasattr(self, "_views"):
+ res = self.db.get("SELECT COUNT(*) AS views FROM planet_views \
+ WHERE post_id = %s", self.id)
+
+ self._views = res.views
+
+ return self._views
+
class Planet(Object):
def get_authors(self):
SELECT *, ts_headline(markup, ranked.query, 'MinWords=100, MaxWords=110') AS markup FROM planet \
JOIN ranked ON planet.id = ranked.id \
WHERE status = %s AND published IS NOT NULL AND published <= NOW() \
- ORDER BY ranked DESC LIMIT 10",
+ ORDER BY ranked DESC LIMIT 25",
"english", what, "english", "published")
return [PlanetEntry(self.backend, e) for e in res]