mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Add simple index WikiRevisionHistoryByPage.
This will eventually replace WikiRevisionsByPage, which stores the full contents of each revision in the column value and is hurting cassandra.
This commit is contained in:
@@ -165,7 +165,7 @@ class WikiRevision(tdb_cassandra.UuidThing, Printable):
|
||||
self.hidden = not self.is_hidden
|
||||
self._commit()
|
||||
return self.hidden
|
||||
|
||||
|
||||
@classmethod
|
||||
def create(cls, pageid, content, author=None, reason=None):
|
||||
kw = dict(pageid=pageid, content=content)
|
||||
@@ -176,13 +176,15 @@ class WikiRevision(tdb_cassandra.UuidThing, Printable):
|
||||
wr = cls(**kw)
|
||||
wr._commit()
|
||||
WikiRevisionsByPage.add_object(wr)
|
||||
WikiRevisionHistoryByPage.add_object(wr)
|
||||
WikiRevisionsRecentBySR.add_object(wr)
|
||||
return wr
|
||||
|
||||
|
||||
def _on_commit(self):
|
||||
WikiRevisionsByPage.add_object(self)
|
||||
WikiRevisionHistoryByPage.add_object(self)
|
||||
WikiRevisionsRecentBySR.add_object(self)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_recent(cls, sr, count=100):
|
||||
return WikiRevisionsRecentBySR.query([sr._id36], count=count)
|
||||
@@ -424,6 +426,23 @@ class WikiPage(tdb_cassandra.Thing):
|
||||
self._id = pageid
|
||||
return tdb_cassandra.Thing._commit(self, *a, **kw)
|
||||
|
||||
|
||||
class WikiRevisionHistoryByPage(tdb_cassandra.View):
|
||||
"""Create a time ordered index of revisions for a wiki page"""
|
||||
_use_db = True
|
||||
_connection_pool = 'main'
|
||||
_view_of = WikiRevision
|
||||
_compare_with = TIME_UUID_TYPE
|
||||
|
||||
@classmethod
|
||||
def _rowkey(cls, wikirevision):
|
||||
return wikirevision.pageid
|
||||
|
||||
@classmethod
|
||||
def _obj_to_column(cls, wikirevision):
|
||||
return {wikirevision._id: ''}
|
||||
|
||||
|
||||
class WikiRevisionsByPage(tdb_cassandra.DenormalizedView):
|
||||
""" Associate revisions with pages """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user