mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Compact GridFS at startup
This commit is contained in:
parent
cfced13e4a
commit
144040f126
3 changed files with 10 additions and 5 deletions
|
@ -289,11 +289,6 @@ def task_cache_actor() -> _Response:
|
||||||
# Cache the actor info
|
# Cache the actor info
|
||||||
update_cached_actor(actor)
|
update_cached_actor(actor)
|
||||||
|
|
||||||
# TODO(tsileo): Also update following (it's in the object)
|
|
||||||
# DB.activities.update_many(
|
|
||||||
# {"meta.object_id": actor.id}, {"$set": {"meta.object": actor.to_dict(embed=True)}}
|
|
||||||
# )
|
|
||||||
|
|
||||||
app.logger.info(f"actor cached for {iri}")
|
app.logger.info(f"actor cached for {iri}")
|
||||||
if not activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]):
|
if not activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]):
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -690,4 +690,8 @@ def update_cached_actor(actor: ap.BaseActivity) -> None:
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
# TODO(tsileo): Also update following (it's in the object)
|
||||||
|
# DB.activities.update_many(
|
||||||
|
# {"meta.object_id": actor.id}, {"$set": {"meta.object": actor.to_dict(embed=True)}}
|
||||||
|
# )
|
||||||
_cache_actor_icon(actor)
|
_cache_actor_icon(actor)
|
||||||
|
|
|
@ -13,6 +13,12 @@ def create_indexes():
|
||||||
if "activities" in DB.collection_names():
|
if "activities" in DB.collection_names():
|
||||||
DB.command("compact", "activities")
|
DB.command("compact", "activities")
|
||||||
|
|
||||||
|
try:
|
||||||
|
MEDIA_CACHE.fs._GridFS__database.command("compact", "fs.files")
|
||||||
|
MEDIA_CACHE.fs._GridFS__database.command("compact", "fs.chunks")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
DB.activities.create_index([(_meta(MetaKey.NOTIFICATION), pymongo.ASCENDING)])
|
DB.activities.create_index([(_meta(MetaKey.NOTIFICATION), pymongo.ASCENDING)])
|
||||||
DB.activities.create_index(
|
DB.activities.create_index(
|
||||||
[(_meta(MetaKey.NOTIFICATION_UNREAD), pymongo.ASCENDING)]
|
[(_meta(MetaKey.NOTIFICATION_UNREAD), pymongo.ASCENDING)]
|
||||||
|
|
Loading…
Reference in a new issue