Search: Squash misuse of datetime.strftime

This commit is contained in:
Keith Mitchell
2012-08-22 12:27:03 -07:00
committed by Neil Williams
parent 6e63366649
commit ab306a0423
2 changed files with 3 additions and 3 deletions

View File

@@ -686,8 +686,8 @@ class FrontController(RedditController):
query = "|".join(query.split())
query = "title:'%s'" % query
rel_range = timedelta(days=3)
start = (article._date - rel_range).strftime("%s")
end = (article._date + rel_range).strftime("%s")
start = int(time.mktime((article._date - rel_range).utctimetuple()))
end = int(time.mktime((article._date + rel_range).utctimetuple()))
nsfw = "nsfw:0" if not (article.over_18 or article._nsfw.findall(article.title)) else ""
query = "(and %s timestamp:%s..%s %s)" % (query, start, end, nsfw)
q = SearchQuery(query, raw_sort="-text_relevance",

View File

@@ -252,7 +252,7 @@ class LinkUploader(CloudSearchUploader):
"subreddit": sr.name,
"reddit": sr.name,
"title": thing.title,
"timestamp": thing._date.strftime("%s"),
"timestamp": int(time.mktime(thing._date.utctimetuple())),
"sr_id": thing.sr_id,
"over18": 1 if nsfw else 0,
"is_self": 1 if thing.is_self else 0,