def query(self):
        q = None
        if self.where == 'overview':
            self.check_modified(self.vuser, 'overview')
            q = queries.get_overview(self.vuser, self.sort, self.time)

        elif self.where == 'comments':
            sup.set_sup_header(self.vuser, 'commented')
            self.check_modified(self.vuser, 'commented')
            q = queries.get_comments(self.vuser, self.sort, self.time)

        elif self.where == 'submitted':
            sup.set_sup_header(self.vuser, 'submitted')
            self.check_modified(self.vuser, 'submitted')
            q = queries.get_submitted(self.vuser, self.sort, self.time)

        elif self.where == 'gilded':
            sup.set_sup_header(self.vuser, 'gilded')
            self.check_modified(self.vuser, 'gilded')
            if self.show == 'given':
                q = queries.get_user_gildings(self.vuser)
            else:
                q = queries.get_gilded_user_comments(self.vuser)

        elif self.where in ('liked', 'disliked'):
            sup.set_sup_header(self.vuser, self.where)
            self.check_modified(self.vuser, self.where)
            if self.where == 'liked':
                q = queries.get_liked(self.vuser)
            else:
                q = queries.get_disliked(self.vuser)

        elif self.where == 'hidden':
            q = queries.get_hidden(self.vuser)

        elif self.where == 'saved':
            srname = request.GET.get('sr')
            if srname and c.user.gold:
                try:
                    sr_id = Subreddit._by_name(srname)._id
                except NotFound:
                    sr_id = None
            else:
                sr_id = None
            q = queries.get_saved(self.vuser, sr_id)

        elif c.user_is_sponsor and self.where == 'promoted':
            q = queries.get_promoted_links(self.vuser._id)

        if q is None:
            return self.abort404()

        return q
Beispiel #2
0
    def query(self):
        q = None
        if self.where == 'overview':
            self.check_modified(self.vuser, 'overview')
            q = queries.get_overview(self.vuser, self.sort, self.time)

        elif self.where == 'comments':
            sup.set_sup_header(self.vuser, 'commented')
            self.check_modified(self.vuser, 'commented')
            q = queries.get_comments(self.vuser, self.sort, self.time)

        elif self.where == 'submitted':
            sup.set_sup_header(self.vuser, 'submitted')
            self.check_modified(self.vuser, 'submitted')
            q = queries.get_submitted(self.vuser, self.sort, self.time)

        elif self.where == 'gilded':
            sup.set_sup_header(self.vuser, 'gilded')
            self.check_modified(self.vuser, 'gilded')
            if self.show == 'given':
                q = queries.get_user_gildings(self.vuser)
            else:
                q = queries.get_gilded_user_comments(self.vuser)

        elif self.where in ('liked', 'disliked'):
            sup.set_sup_header(self.vuser, self.where)
            self.check_modified(self.vuser, self.where)
            if self.where == 'liked':
                q = queries.get_liked(self.vuser)
            else:
                q = queries.get_disliked(self.vuser)

        elif self.where == 'hidden':
            q = queries.get_hidden(self.vuser)

        elif self.where == 'saved':
            srname = request.GET.get('sr')
            if srname and c.user.gold:
                try:
                    sr_id = Subreddit._by_name(srname)._id
                except NotFound:
                    sr_id = None
            else:
                sr_id = None
            q = queries.get_saved(self.vuser, sr_id)

        elif c.user_is_sponsor and self.where == 'promoted':
            q = queries.get_promoted_links(self.vuser._id)

        if q is None:
            return self.abort404()

        return q
Beispiel #3
0
    def query(self):
        q = None
        if self.where == "overview":
            self.check_modified(self.vuser, "overview")
            q = queries.get_overview(self.vuser, self.sort, self.time)

        elif self.where == "comments":
            sup.set_sup_header(self.vuser, "commented")
            self.check_modified(self.vuser, "commented")
            q = queries.get_comments(self.vuser, self.sort, self.time)

        elif self.where == "submitted":
            sup.set_sup_header(self.vuser, "submitted")
            self.check_modified(self.vuser, "submitted")
            q = queries.get_submitted(self.vuser, self.sort, self.time)

        elif self.where == "gilded":
            sup.set_sup_header(self.vuser, "gilded")
            self.check_modified(self.vuser, "gilded")
            if self.show == "given":
                q = queries.get_user_gildings(self.vuser)
            else:
                q = queries.get_gilded_user_comments(self.vuser)

        elif self.where in ("liked", "disliked"):
            sup.set_sup_header(self.vuser, self.where)
            self.check_modified(self.vuser, self.where)
            if self.where == "liked":
                q = queries.get_liked(self.vuser)
            else:
                q = queries.get_disliked(self.vuser)

        elif self.where == "hidden":
            q = queries.get_hidden(self.vuser)

        elif self.where == "saved":
            srname = request.GET.get("sr")
            if srname and c.user.gold:
                try:
                    sr_id = Subreddit._by_name(srname)._id
                except NotFound:
                    sr_id = None
            else:
                sr_id = None
            q = queries.get_saved(self.vuser, sr_id)

        elif c.user_is_sponsor and self.where == "promoted":
            q = queries.get_promoted_links(self.vuser._id)

        if q is None:
            return self.abort404()

        return q
Beispiel #4
0
import datetime

from pylons import g

from r2.lib.db.queries import get_gilded_user_comments
from r2.lib.utils import Storage
from r2.models import GildingsByDay, Thing, Comment
from r2.models.query_cache import CachedQueryMutator

date = datetime.datetime.now(g.tz)
earliest_date = datetime.datetime(2012, 10, 01, tzinfo=g.tz)

already_seen = set()

with CachedQueryMutator() as m:
    while date > earliest_date:
        gildings = GildingsByDay.get_gildings(date)
        fullnames = [x["thing"] for x in gildings]
        things = Thing._by_fullname(fullnames, data=True, return_dict=False)
        comments = {t._fullname: t for t in things if isinstance(t, Comment)}

        for gilding in gildings:
            fullname = gilding["thing"]
            if fullname in comments and fullname not in already_seen:
                thing = gilding["thing"] = comments[fullname]
                gilding_object = Storage(gilding)
                m.insert(get_gilded_user_comments(thing.author_id),
                         [gilding_object])
                already_seen.add(fullname)
        date -= datetime.timedelta(days=1)
from pylons import app_globals as g

from r2.lib.db.queries import get_gilded_user_comments
from r2.lib.utils import Storage
from r2.models import GildingsByDay, Thing, Comment
from r2.models.query_cache import CachedQueryMutator


date = datetime.datetime.now(g.tz)
earliest_date = datetime.datetime(2012, 10, 01, tzinfo=g.tz)

already_seen = set()

with CachedQueryMutator() as m:
    while date > earliest_date:
        gildings = GildingsByDay.get_gildings(date)
        fullnames = [x["thing"] for x in gildings]
        things = Thing._by_fullname(fullnames, data=True, return_dict=False)
        comments = {t._fullname: t for t in things if isinstance(t, Comment)}

        for gilding in gildings:
            fullname = gilding["thing"]
            if fullname in comments and fullname not in already_seen:
                thing = gilding["thing"] = comments[fullname]
                gilding_object = Storage(gilding)
                m.insert(get_gilded_user_comments(thing.author_id),
                         [gilding_object])
                already_seen.add(fullname)
        date -= datetime.timedelta(days=1)
Beispiel #6
0
import datetime

from pylons import g

from r2.lib.db.queries import get_gilded_user_comments
from r2.lib.utils import Storage
from r2.models import GildingsByDay, Thing, Comment
from r2.models.query_cache import CachedQueryMutator


date = datetime.datetime.now(g.tz)
earliest_date = datetime.datetime(2012, 10, 01, tzinfo=g.tz)

already_seen = set()

with CachedQueryMutator() as m:
    while date > earliest_date:
        gildings = GildingsByDay.get_gildings(date)
        fullnames = [x["thing"] for x in gildings]
        things = Thing._by_fullname(fullnames, data=True, return_dict=False)
        comments = {t._fullname: t for t in things if isinstance(t, Comment)}

        for gilding in gildings:
            fullname = gilding["thing"]
            if fullname in comments and fullname not in already_seen:
                thing = gilding["thing"] = comments[fullname]
                gilding_object = Storage(gilding)
                m.insert(get_gilded_user_comments(thing.author_id), [gilding_object])
                already_seen.add(fullname)
        date -= datetime.timedelta(days=1)