galaxy: big refactor

Main changes:
  - Multiple Galaxy objects can now exist at the same time in DB. This allows for ruling a new galaxy while still
    displaying the old one.
  - The criteria to quickly know whether a user is a possible citizen is now a simple query on picture count. This
    avoids a very complicated query to database, that could often result in huge working memory load. With this change,
    it should be possible to run the galaxy even on a vanilla Postgres that didn't receive fine tuning for the Sith's
    galaxy.
This commit is contained in:
Skia
2023-04-14 17:33:11 +02:00
parent 1aa3bb8cc4
commit 31093fff43
7 changed files with 339 additions and 196 deletions

View File

@ -49,11 +49,10 @@ class Command(BaseCommand):
logger.setLevel(logging.NOTSET)
logger.info("The Galaxy is being ruled by the Sith.")
Galaxy.rule()
logger.info(
"Caching current Galaxy state for a quicker display of the Empire's power."
)
Galaxy.make_state()
galaxy = Galaxy.objects.create()
galaxy.rule()
logger.info("Sending old galaxies' remains to garbage.")
Galaxy.objects.filter(state__isnull=True).delete()
logger.info("Ruled the galaxy in {} queries.".format(len(connection.queries)))
if options["verbosity"] > 2: