not published in feed. devmode try
This commit is contained in:
parent
956dc3915c
commit
8e7e070948
|
@ -1,6 +1,6 @@
|
||||||
from resolvers.auth import login, sign_out, is_email_free, register, confirm
|
from resolvers.auth import login, sign_out, is_email_free, register, confirm
|
||||||
from resolvers.zine import create_shout, get_shout_by_slug, \
|
from resolvers.zine import create_shout, get_shout_by_slug, \
|
||||||
top_month, top_overall, recent_shouts, top_viewed, shouts_by_authors, shouts_by_topics, shouts_by_communities, \
|
top_month, top_overall, recent_shouts, recent_all, top_viewed, shouts_by_authors, shouts_by_topics, shouts_by_communities, \
|
||||||
shouts_candidates, shouts_reviewed, shouts_subscribed
|
shouts_candidates, shouts_reviewed, shouts_subscribed
|
||||||
from resolvers.profile import get_users_by_slugs, get_current_user
|
from resolvers.profile import get_users_by_slugs, get_current_user
|
||||||
from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \
|
from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \
|
||||||
|
@ -20,6 +20,7 @@ __all__ = [
|
||||||
"get_users_by_slugs",
|
"get_users_by_slugs",
|
||||||
"get_shout_by_slug",
|
"get_shout_by_slug",
|
||||||
"recent_shouts",
|
"recent_shouts",
|
||||||
|
"recent_all",
|
||||||
"shouts_by_topics",
|
"shouts_by_topics",
|
||||||
"shouts_by_authors",
|
"shouts_by_authors",
|
||||||
"shouts_by_communities",
|
"shouts_by_communities",
|
||||||
|
|
|
@ -98,6 +98,21 @@ class ShoutsCache:
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
ShoutsCache.recent_shouts = shouts
|
ShoutsCache.recent_shouts = shouts
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def prepare_recent_all():
|
||||||
|
with local_session() as session:
|
||||||
|
stmt = select(Shout).\
|
||||||
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
|
where(Shout.publishedAt != None).\
|
||||||
|
limit(ShoutsCache.limit)
|
||||||
|
shouts = []
|
||||||
|
for row in session.execute(stmt):
|
||||||
|
shout = row.Shout
|
||||||
|
shout.ratings = await ShoutRatingStorage.get_ratings(shout.slug)
|
||||||
|
shouts.append(shout)
|
||||||
|
async with ShoutsCache.lock:
|
||||||
|
ShoutsCache.recent_all = shouts
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def prepare_recent_commented():
|
async def prepare_recent_commented():
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
@ -184,6 +199,7 @@ class ShoutsCache:
|
||||||
await ShoutsCache.prepare_top_overall()
|
await ShoutsCache.prepare_top_overall()
|
||||||
await ShoutsCache.prepare_top_viewed()
|
await ShoutsCache.prepare_top_viewed()
|
||||||
await ShoutsCache.prepare_recent_shouts()
|
await ShoutsCache.prepare_recent_shouts()
|
||||||
|
await ShoutsCache.prepare_recent_all()
|
||||||
await ShoutsCache.prepare_recent_commented()
|
await ShoutsCache.prepare_recent_commented()
|
||||||
print("shouts cache update finished")
|
print("shouts cache update finished")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -225,13 +241,18 @@ async def top_overall(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.top_overall[(page - 1) * size : page * size]
|
return ShoutsCache.top_overall[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@query.field("recents")
|
@query.field("recentPublished")
|
||||||
async def recent_shouts(_, info, page, size):
|
async def recent_shouts(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.recent_shouts[(page - 1) * size : page * size]
|
return ShoutsCache.recent_shouts[(page - 1) * size : page * size]
|
||||||
|
|
||||||
|
@query.field("recentAll")
|
||||||
|
async def recent_all(_, info, page, size):
|
||||||
|
async with ShoutsCache.lock:
|
||||||
|
return ShoutsCache.recent_all[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@query.field("recentCommented")
|
@query.field("recentCommented")
|
||||||
async def recent_shouts(_, info, page, size):
|
async def recent_commented(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.recent_commented[(page - 1) * size : page * size]
|
return ShoutsCache.recent_commented[(page - 1) * size : page * size]
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,10 @@ type Query {
|
||||||
topViewed(page: Int!, size: Int!): [Shout]!
|
topViewed(page: Int!, size: Int!): [Shout]!
|
||||||
topMonth(page: Int!, size: Int!): [Shout]!
|
topMonth(page: Int!, size: Int!): [Shout]!
|
||||||
topOverall(page: Int!, size: Int!): [Shout]!
|
topOverall(page: Int!, size: Int!): [Shout]!
|
||||||
recents(page: Int!, size: Int!): [Shout]!
|
recentPublished(page: Int!, size: Int!): [Shout]!
|
||||||
|
|
||||||
|
# feed
|
||||||
|
recentAll(page: Int!, size: Int!): [Shout]!
|
||||||
|
|
||||||
# topics
|
# topics
|
||||||
topicsBySlugs(slugs: [String]): [Topic]!
|
topicsBySlugs(slugs: [String]): [Topic]!
|
||||||
|
|
|
@ -8,7 +8,14 @@ if __name__ == '__main__':
|
||||||
inbox_service = len(sys.argv) > 1 and sys.argv[1] == "inbox"
|
inbox_service = len(sys.argv) > 1 and sys.argv[1] == "inbox"
|
||||||
if dev_mode:
|
if dev_mode:
|
||||||
print("DEV MODE")
|
print("DEV MODE")
|
||||||
uvicorn.run("main:app", host="0.0.0.0", port=8080, ssl_keyfile="discours.key", ssl_certfile="discours.crt", reload=True)
|
headers = [
|
||||||
|
("Access-Control-Allow-Methods", "GET, POST, OPTIONS, HEAD"),
|
||||||
|
("Access-Control-Allow-Origin", "*"),
|
||||||
|
("Access-Control-Allow-Headers", "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"),
|
||||||
|
("Access-Control-Expose-Headers", "Content-Length,Content-Range"),
|
||||||
|
("Access-Control-Allow-Credentials", "true")
|
||||||
|
]
|
||||||
|
uvicorn.run("main:app", host="localhost", port=8080, headers=headers) #, ssl_keyfile="discours.key", ssl_certfile="discours.crt", reload=True)
|
||||||
elif inbox_service:
|
elif inbox_service:
|
||||||
print("INBOX SERVICE")
|
print("INBOX SERVICE")
|
||||||
uvicorn.run("inbox_main:app", host="0.0.0.0", port=INBOX_SERVICE_PORT)
|
uvicorn.run("inbox_main:app", host="0.0.0.0", port=INBOX_SERVICE_PORT)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user