Added indexes.
This commit is contained in:
parent
3fc33eaa12
commit
8a6aa33974
@ -5,6 +5,11 @@ from snek.system.template import whitelist_attributes
|
|||||||
class ChannelMessageService(BaseService):
|
class ChannelMessageService(BaseService):
|
||||||
mapper_name = "channel_message"
|
mapper_name = "channel_message"
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self._configured_indexes = False
|
||||||
|
|
||||||
async def maintenance(self):
|
async def maintenance(self):
|
||||||
args = {}
|
args = {}
|
||||||
async for message in self.find():
|
async for message in self.find():
|
||||||
@ -66,6 +71,12 @@ class ChannelMessageService(BaseService):
|
|||||||
print(ex, flush=True)
|
print(ex, flush=True)
|
||||||
|
|
||||||
if await super().save(model):
|
if await super().save(model):
|
||||||
|
if not self._configured_indexes:
|
||||||
|
if not self.mapper.db["channel_message"].has_index(['is_final','user_uid','channel_uid']):
|
||||||
|
self.mapper.db["channel_message"].create_index(['is_final','user_uid','channel_uid'], unique=False)
|
||||||
|
if not self.mapper.db["channel_message"].has_index(['deleted_at']):
|
||||||
|
self.mapper.db["channel_message"].create_index(['deleted_at'], unique=False)
|
||||||
|
self._configured_indexes = True
|
||||||
return model
|
return model
|
||||||
raise Exception(f"Failed to create channel message: {model.errors}.")
|
raise Exception(f"Failed to create channel message: {model.errors}.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user