forked from rDrama/rDrama
master
parent
b036390fea
commit
17b3b155b6
|
@ -160,15 +160,21 @@ def front_all(v, sub=None):
|
||||||
t=request.values.get('t', defaulttime)
|
t=request.values.get('t', defaulttime)
|
||||||
ccmode=request.values.get('ccmode', "false")
|
ccmode=request.values.get('ccmode', "false")
|
||||||
|
|
||||||
|
try: gt=int(request.values.get("utc_greater_than", 0))
|
||||||
|
except: gt=0
|
||||||
|
|
||||||
|
try: lt=int(request.values.get("utc_less_than", 0))
|
||||||
|
except: lt=0
|
||||||
|
|
||||||
ids, next_exists = frontlist(sort=sort,
|
ids, next_exists = frontlist(sort=sort,
|
||||||
page=page,
|
page=page,
|
||||||
t=t,
|
t=t,
|
||||||
v=v,
|
v=v,
|
||||||
ccmode=ccmode,
|
ccmode=ccmode,
|
||||||
filter_words=v.filter_words if v else [],
|
filter_words=v.filter_words if v else [],
|
||||||
gt=int(request.values.get("utc_greater_than", 0)),
|
gt=gt,
|
||||||
lt=int(request.values.get("utc_less_than", 0)),
|
lt=lt,
|
||||||
sub=sub
|
sub=sub,
|
||||||
)
|
)
|
||||||
|
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
@ -255,21 +261,25 @@ def front_all(v, sub=None):
|
||||||
|
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None, sub=None):
|
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=0, lt=0, sub=None):
|
||||||
|
|
||||||
posts = g.db.query(Submission)
|
posts = g.db.query(Submission)
|
||||||
|
|
||||||
if sub: posts = posts.filter_by(sub=sub.name)
|
if sub: posts = posts.filter_by(sub=sub.name)
|
||||||
|
|
||||||
if t == 'all': cutoff = 0
|
if gt: posts = posts.filter(Submission.created_utc > gt)
|
||||||
else:
|
if lt: posts = posts.filter(Submission.created_utc < lt)
|
||||||
now = int(time.time())
|
|
||||||
if t == 'hour': cutoff = now - 3600
|
if not gt and not lt:
|
||||||
elif t == 'week': cutoff = now - 604800
|
if t == 'all': cutoff = 0
|
||||||
elif t == 'month': cutoff = now - 2592000
|
else:
|
||||||
elif t == 'year': cutoff = now - 31536000
|
now = int(time.time())
|
||||||
else: cutoff = now - 86400
|
if t == 'hour': cutoff = now - 3600
|
||||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
elif t == 'week': cutoff = now - 604800
|
||||||
|
elif t == 'month': cutoff = now - 2592000
|
||||||
|
elif t == 'year': cutoff = now - 31536000
|
||||||
|
else: cutoff = now - 86400
|
||||||
|
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||||
|
|
||||||
if (ccmode == "true"):
|
if (ccmode == "true"):
|
||||||
posts = posts.filter(Submission.club == True)
|
posts = posts.filter(Submission.club == True)
|
||||||
|
@ -296,9 +306,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
||||||
for word in filter_words:
|
for word in filter_words:
|
||||||
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
|
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
|
||||||
|
|
||||||
if gt: posts = posts.filter(Submission.created_utc > gt)
|
|
||||||
if lt: posts = posts.filter(Submission.created_utc < lt)
|
|
||||||
|
|
||||||
if not (v and v.shadowbanned):
|
if not (v and v.shadowbanned):
|
||||||
posts = posts.join(User, User.id == Submission.author_id).filter(User.shadowbanned == None)
|
posts = posts.join(User, User.id == Submission.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue