jsonify marseys

pull/15/head
justcool393 2022-11-26 16:17:42 -06:00
parent c3728aebab
commit 28c0fb6c73
2 changed files with 12 additions and 2 deletions

View File

@ -21,3 +21,13 @@ class Marsey(Base):
def __repr__(self):
return f"<Marsey(name={self.name})>"
def json(self):
return {
"name": self.name,
"author_id": self.author_id,
"submitter_id": self.submitter_id,
"tags": self.tags.split(' '),
"count": self.count,
"created_utc": self.created_utc
}

View File

@ -38,7 +38,7 @@ def marseys(v):
return render_template("marseys.html", v=v, marseys=marseys)
@app.get("/emojis")
def marsey_list():
def emoji_list():
return jsonify(get_emojis(g.db))
@cache.cached(timeout=86400, key_prefix=MARSEYS_CACHE_KEY)
@ -54,7 +54,7 @@ def get_marseys(db:scoped_session):
@cache.cached(timeout=600, key_prefix=EMOJIS_CACHE_KEY)
def get_emojis(db:scoped_session):
emojis = get_marseys(db)
emojis = [m.json() for m in get_marseys(db)]
for src in EMOJI_SRCS:
with open(src, "r", encoding="utf-8") as f:
emojis = emojis + json.load(f)