def query(self): if self.where == "messages": q = queries.get_inbox_messages(c.user) elif self.where == "comments": q = queries.get_inbox_comments(c.user) elif self.where == "selfreply": q = queries.get_inbox_selfreply(c.user) elif self.where == "inbox": q = queries.get_inbox(c.user) elif self.where == "unread": q = queries.get_unread_inbox(c.user) elif self.where == "sent": q = queries.get_sent(c.user) elif self.where == "moderator" and self.subwhere == "unread": if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = Subreddit._byID(srids, data=False, return_dict=False) q = queries.merge_results(*[queries.get_unread_subreddit_messages(s) for s in srs]) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where == "moderator": if c.have_mod_messages and self.mark != "false": c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != "sent": # reset the inbox if c.have_messages and self.mark != "false": c.user.msgtime = False c.user._commit() return q
def gen_keys(): yield promoted_memo_key # just let this one do its own writing load_all_reddits() yield queries.get_all_comments().iden l_q = Link._query(Link.c._spam == (True, False), Link.c._deleted == (True, False), sort=desc('_date'), data=True, ) for link in fetch_things2(l_q, verbosity): yield comments_key(link._id) yield last_modified_key(link, 'comments') a_q = Account._query(Account.c._spam == (True, False), sort=desc('_date'), ) for account in fetch_things2(a_q, verbosity): yield messages_key(account._id) yield last_modified_key(account, 'overview') yield last_modified_key(account, 'commented') yield last_modified_key(account, 'submitted') yield last_modified_key(account, 'liked') yield last_modified_key(account, 'disliked') yield queries.get_comments(account, 'new', 'all').iden yield queries.get_submitted(account, 'new', 'all').iden yield queries.get_liked(account).iden yield queries.get_disliked(account).iden yield queries.get_hidden(account).iden yield queries.get_saved(account).iden yield queries.get_inbox_messages(account).iden yield queries.get_unread_messages(account).iden yield queries.get_inbox_comments(account).iden yield queries.get_unread_comments(account).iden yield queries.get_inbox_selfreply(account).iden yield queries.get_unread_selfreply(account).iden yield queries.get_sent(account).iden sr_q = Subreddit._query(Subreddit.c._spam == (True, False), sort=desc('_date'), ) for sr in fetch_things2(sr_q, verbosity): yield last_modified_key(sr, 'stylesheet_contents') yield queries.get_links(sr, 'hot', 'all').iden yield queries.get_links(sr, 'new', 'all').iden for sort in 'top', 'controversial': for time in 'hour', 'day', 'week', 'month', 'year', 'all': yield queries.get_links(sr, sort, time, merge_batched=False).iden yield queries.get_spam_links(sr).iden yield queries.get_spam_comments(sr).iden yield queries.get_reported_links(sr).iden yield queries.get_reported_comments(sr).iden yield queries.get_subreddit_messages(sr).iden yield queries.get_unread_subreddit_messages(sr).iden
def gen_keys(): yield promoted_memo_key # just let this one do its own writing load_all_reddits() yield queries.get_all_comments().iden l_q = Link._query( Link.c._spam == (True, False), Link.c._deleted == (True, False), sort=desc("_date"), data=True ) for link in fetch_things2(l_q, verbosity): yield comments_key(link._id) yield last_modified_key(link, "comments") a_q = Account._query(Account.c._spam == (True, False), sort=desc("_date")) for account in fetch_things2(a_q, verbosity): yield messages_key(account._id) yield last_modified_key(account, "overview") yield last_modified_key(account, "commented") yield last_modified_key(account, "submitted") yield last_modified_key(account, "liked") yield last_modified_key(account, "disliked") yield queries.get_comments(account, "new", "all").iden yield queries.get_submitted(account, "new", "all").iden yield queries.get_liked(account).iden yield queries.get_disliked(account).iden yield queries.get_hidden(account).iden yield queries.get_saved(account).iden yield queries.get_inbox_messages(account).iden yield queries.get_unread_messages(account).iden yield queries.get_inbox_comments(account).iden yield queries.get_unread_comments(account).iden yield queries.get_inbox_selfreply(account).iden yield queries.get_unread_selfreply(account).iden yield queries.get_sent(account).iden sr_q = Subreddit._query(Subreddit.c._spam == (True, False), sort=desc("_date")) for sr in fetch_things2(sr_q, verbosity): yield last_modified_key(sr, "stylesheet_contents") yield queries.get_links(sr, "hot", "all").iden yield queries.get_links(sr, "new", "all").iden for sort in "top", "controversial": for time in "hour", "day", "week", "month", "year", "all": yield queries.get_links(sr, sort, time, merge_batched=False).iden yield queries.get_spam_links(sr).iden yield queries.get_spam_comments(sr).iden yield queries.get_reported_links(sr).iden yield queries.get_reported_comments(sr).iden yield queries.get_subreddit_messages(sr).iden yield queries.get_unread_subreddit_messages(sr).iden
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [sr for sr in Subreddit._byID(srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, 'mail')] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if self.mark != 'false': c.user.clear_moderator_message_count() # the query is handled by the builder on the moderator page return elif self.where == 'notifications': if self.mark != 'false': c.user.clear_notification_count() q = queries.get_unread_notifications(c.user) elif self.where == 'reset_message_counts': g.log.debug("resetting message count") c.user.message_count = 2 c.user.moderator_message_count = 1 c.user.notification_count = 7 c.user._commit() q = queries.get_inbox(c.user) else: return self.abort404() # Clear the message count under most circumstances... if self.where not in ('sent', 'reset_message_counts', 'notifications'): if self.mark != 'false': c.user.clear_message_count() return q
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'mentions': q = queries.get_inbox_comment_mentions(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [ sr for sr in Subreddit._byID( srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, 'mail') ] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.have_messages = False c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == "messages": q = queries.get_inbox_messages(c.user) elif self.where == "comments": q = queries.get_inbox_comments(c.user) elif self.where == "selfreply": q = queries.get_inbox_selfreply(c.user) elif self.where == "mentions": q = queries.get_inbox_comment_mentions(c.user) elif self.where == "inbox": q = queries.get_inbox(c.user) elif self.where == "unread": q = queries.get_unread_inbox(c.user) elif self.where == "sent": q = queries.get_sent(c.user) elif self.where == "multi" and self.subwhere == "unread": q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == "moderator" and self.subwhere == "unread": if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [ sr for sr in Subreddit._byID(srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, "mail") ] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ("moderator", "multi"): if c.have_mod_messages and self.mark != "false": c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != "sent": # reset the inbox if c.have_messages and self.mark != "false": c.have_messages = False c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'mentions': q = queries.get_inbox_comment_mentions(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [sr for sr in Subreddit._byID(srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, 'mail')] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.have_messages = False c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.merge_results( *[queries.get_unread_subreddit_messages(s) for s in self.srs]) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = Subreddit._byID(srids, data=False, return_dict=False) q = queries.merge_results( *[queries.get_unread_subreddit_messages(s) for s in srs]) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.merge_results(*[queries.get_unread_subreddit_messages(s) for s in self.srs]) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = Subreddit._byID(srids, data = False, return_dict = False) q = queries.merge_results( *[queries.get_unread_subreddit_messages(s) for s in srs]) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.user.msgtime = False c.user._commit() return q