add unread question count

This commit is contained in:
mst 2024-11-26 15:13:17 +03:00
parent bcf7972f77
commit f316d89e9d

6
app.py
View file

@ -105,8 +105,8 @@ def inject_stuff():
app.logger.debug("[CatAsk] app.context_processor inject_stuff() triggered")
cfg = func.loadJSON(const.configFile)
# for 1.6.0 or later
# questionCount = getQuestionCount()
return dict(metadata=func.generateMetadata(), len=len, str=str, const=const, cfg=cfg, logged_in=logged_in, version_id=const.version_id, version=const.version, appName=const.appName)
questionCount = int(getQuestionCount())
return dict(metadata=func.generateMetadata(), len=len, str=str, const=const, cfg=cfg, logged_in=logged_in, version_id=const.version_id, version=const.version, appName=const.appName, questionCount=questionCount)
# -- template filters --
@app.template_filter('render_markdown')
@ -163,6 +163,8 @@ def inbox():
cursor.execute("SELECT * FROM questions WHERE answered=%s ORDER BY creation_date DESC", (False,))
questions = cursor.fetchall()
for question in questions:
cursor.execute("UPDATE questions SET unread=%s WHERE id=%s", (False, question['id']))
cursor.close()
conn.close()