mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Start working on indexes
This commit is contained in:
parent
2464dd8782
commit
269c5135c2
2 changed files with 34 additions and 0 deletions
|
@ -3,4 +3,5 @@ ADD . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
ENV FLASK_APP=app.py
|
ENV FLASK_APP=app.py
|
||||||
|
RUN python -c "import config; config.create_indexes()"
|
||||||
CMD ["gunicorn", "-t", "300", "-w", "2", "-b", "0.0.0.0:5005", "--log-level", "debug", "app:app"]
|
CMD ["gunicorn", "-t", "300", "-w", "2", "-b", "0.0.0.0:5005", "--log-level", "debug", "app:app"]
|
||||||
|
|
33
config.py
33
config.py
|
@ -11,6 +11,7 @@ from itsdangerous import JSONWebSignatureSerializer
|
||||||
from little_boxes import strtobool
|
from little_boxes import strtobool
|
||||||
from little_boxes.activitypub import DEFAULT_CTX
|
from little_boxes.activitypub import DEFAULT_CTX
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
import pymongo
|
||||||
|
|
||||||
from utils.key import KEY_DIR
|
from utils.key import KEY_DIR
|
||||||
from utils.key import get_key
|
from utils.key import get_key
|
||||||
|
@ -101,6 +102,38 @@ GRIDFS = mongo_client[f"{DB_NAME}_gridfs"]
|
||||||
MEDIA_CACHE = MediaCache(GRIDFS, USER_AGENT)
|
MEDIA_CACHE = MediaCache(GRIDFS, USER_AGENT)
|
||||||
|
|
||||||
|
|
||||||
|
def create_indexes():
|
||||||
|
DB.activities.create_index([("remote_id", pymongo.ASCENDING)])
|
||||||
|
|
||||||
|
# Index for the block query
|
||||||
|
DB.activities.create_index(
|
||||||
|
[
|
||||||
|
("box", pymongo.ASCENDING),
|
||||||
|
("type", pymongo.ASCENDING),
|
||||||
|
("meta.undo", pymongo.ASCENDING),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Index for count queries
|
||||||
|
DB.activities.create_index(
|
||||||
|
[
|
||||||
|
("box", pymongo.ASCENDING),
|
||||||
|
("type", pymongo.ASCENDING),
|
||||||
|
("meta.undo", pymongo.ASCENDING),
|
||||||
|
("meta.deleted", pymongo.ASCENDING),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
DB.activities.create_index(
|
||||||
|
[
|
||||||
|
("type", pymongo.ASCENDING),
|
||||||
|
("activity.object.type", pymongo.ASCENDING),
|
||||||
|
("activity.object.inReplyTo", pymongo.ASCENDING),
|
||||||
|
("meta.deleted", pymongo.ASCENDING),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _drop_db():
|
def _drop_db():
|
||||||
if not DEBUG_MODE:
|
if not DEBUG_MODE:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue