Reformat files with black

This commit is contained in:
Thomas Sileo 2019-07-04 23:24:25 +02:00
parent 9e25cad86c
commit 2a0b348796

31
app.py
View file

@ -1579,9 +1579,15 @@ def admin_notifications():
else: else:
nend = inbox_data[-1]["_id"].generation_time.isoformat() nend = inbox_data[-1]["_id"].generation_time.isoformat()
print(nstart, nend) print(nstart, nend)
notifs = list(DB.notifications.find({"datetime": {"$lte": nstart, "$gt": nend}}).sort("_id", -1).limit(50)) notifs = list(
DB.notifications.find({"datetime": {"$lte": nstart, "$gt": nend}})
.sort("_id", -1)
.limit(50)
)
inbox_data.extend(notifs) inbox_data.extend(notifs)
inbox_data = sorted(inbox_data, reverse=True, key=lambda doc: doc["_id"].generation_time) inbox_data = sorted(
inbox_data, reverse=True, key=lambda doc: doc["_id"].generation_time
)
print(inbox_data) print(inbox_data)
return render_template( return render_template(
@ -1965,8 +1971,7 @@ def api_new_question():
open_for = int(_user_api_arg("open_for")) open_for = int(_user_api_arg("open_for"))
choices = { choices = {
"endTime": ap.format_datetime( "endTime": ap.format_datetime(
datetime.now().astimezone() datetime.now().astimezone() + timedelta(minutes=open_for)
+ timedelta(minutes=open_for)
) )
} }
of = _user_api_arg("of") of = _user_api_arg("of")
@ -2971,9 +2976,17 @@ def task_fetch_remote_question():
{"box": Box.INBOX.value, "remote_id": iri} {"box": Box.INBOX.value, "remote_id": iri}
) )
remote_question = get_backend().fetch_iri(iri, no_cache=True) remote_question = get_backend().fetch_iri(iri, no_cache=True)
if local_question["meta"].get("voted_for") or local_question["meta"]["subscribed"]: if (
DB.notifications.insert_one({"type": "question_ended", "datetime": datetime.now(timezone.utc).isoformat(), local_question["meta"].get("voted_for")
"activity": remote_question}) or local_question["meta"]["subscribed"]
):
DB.notifications.insert_one(
{
"type": "question_ended",
"datetime": datetime.now(timezone.utc).isoformat(),
"activity": remote_question,
}
)
DB.activities.update_one( DB.activities.update_one(
{"remote_id": iri, "box": Box.INBOX.value}, {"remote_id": iri, "box": Box.INBOX.value},
@ -3003,9 +3016,7 @@ def task_update_question():
try: try:
app.logger.info(f"Updating question {iri}") app.logger.info(f"Updating question {iri}")
cc = [ID + "/followers"] cc = [ID + "/followers"]
doc = DB.activities.find_one( doc = DB.activities.find_one({"box": Box.OUTBOX.value, "remote_id": iri})
{"box": Box.OUTBOX.value, "remote_id": iri}
)
_add_answers_to_question(doc) _add_answers_to_question(doc)
question = ap.Question(**doc["activity"]["object"]) question = ap.Question(**doc["activity"]["object"])