This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 9aed0b9adc362652990381261bade3c6924cec9a Author: Sebb <[email protected]> AuthorDate: Tue Nov 23 20:55:39 2021 +0000 Don't try to recreate the index name --- server/plugins/background.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/plugins/background.py b/server/plugins/background.py index de5437f..8ebd351 100644 --- a/server/plugins/background.py +++ b/server/plugins/background.py @@ -62,13 +62,13 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict: limit = database.max_lists # Fetch aggregations of all public emails - s = Search(using=db.client, index=database.db_prefix + "-mbox").filter( + s = Search(using=db.client, index=db.dbs.mbox).filter( "term", private=False ) s.aggs.bucket("per_list", "terms", field="list_raw", size=limit) res = await db.search( - index=database.db_prefix + "-mbox", body=s.to_dict(), size=0 + index=db.dbs.mbox, body=s.to_dict(), size=0 ) for ml in res["aggregations"]["per_list"]["buckets"]: @@ -79,13 +79,13 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict: } # Ditto, for private emails - s = Search(using=db.client, index=database.db_prefix + "-mbox").filter( + s = Search(using=db.client, index=db.dbs.mbox).filter( "term", private=True ) s.aggs.bucket("per_list", "terms", field="list_raw", size=limit) res = await db.search( - index=database.db_prefix + "-mbox", body=s.to_dict(), size=0 + index=db.dbs.mbox, body=s.to_dict(), size=0 ) for ml in res["aggregations"]["per_list"]["buckets"]: @@ -96,12 +96,12 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict: } # Get 90 day activity, if any - s = Search(using=db.client, index=database.db_prefix + "-mbox") + s = Search(using=db.client, index=db.dbs.mbox) s = s.filter('range', date = {'gte': ACTIVITY_TIMESPAN}) s.aggs.bucket("per_list", "terms", field="list_raw", size=limit) res = await db.search( - index=database.db_prefix + "-mbox", body=s.to_dict(), size=0 + index=db.dbs.mbox, body=s.to_dict(), size=0 ) for ml in res["aggregations"]["per_list"]["buckets"]: @@ -124,7 +124,7 @@ async def get_public_activity(database: plugins.configuration.DBConfig) -> dict: # Fetch aggregations of all public emails s = ( - Search(using=db, index=database.db_prefix + "-mbox") + Search(using=db, index=db.dbs.mbox) .query("match", private=False) .filter("range", date={"lt": "now+1d", "gt": "now-14d"}) ) @@ -136,7 +136,7 @@ async def get_public_activity(database: plugins.configuration.DBConfig) -> dict: ) res = await db.search( - index=database.db_prefix + "-mbox", body=s.to_dict(), size=0 + index=db.dbs.mbox, body=s.to_dict(), size=0 ) no_emails = res["hits"]["total"]["value"] @@ -152,12 +152,12 @@ async def get_public_activity(database: plugins.configuration.DBConfig) -> dict: thread_count = 0 s = ( - Search(using=db.client, index=database.db_prefix + "-mbox") + Search(using=db.client, index=db.dbs.mbox) .query("match", private=False) .filter("range", date={"lt": "now+1d", "gt": "now-14d"}) ) async for doc in db.scan( - index=database.db_prefix + "-mbox", + index=db.dbs.mbox, query=s.to_dict(), _source_includes=[ "message-id",
