Skip to content

Commit

Permalink
fix: lookup user object operator to pass to CrawlConfig.add_new_crawl (
Browse files Browse the repository at this point in the history
…#1254)

fixes #1253 
Co-authored-by: Ilya Kreymer <[email protected]>
  • Loading branch information
tw4l authored Oct 6, 2023
1 parent fa86555 commit 748c867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/btrixcloud/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def __init__(
super().__init__()

self.crawl_config_ops = crawl_config_ops
self.user_ops = crawl_config_ops.user_manager
self.crawl_ops = crawl_ops
self.org_ops = org_ops
self.coll_ops = coll_ops
Expand Down Expand Up @@ -1261,8 +1262,9 @@ async def sync_cronjob_crawl(self, data: MCDecoratorSyncData):
return {"attachments": []}

# db create
user = await self.user_ops.get_user_by_id(uuid.UUID(userid))
await self.crawl_config_ops.add_new_crawl(
crawl_id, crawlconfig, uuid.UUID(userid), manual=False
crawl_id, crawlconfig, user, manual=False
)
print("Scheduled Crawl Created: " + crawl_id)

Expand Down
4 changes: 4 additions & 0 deletions backend/btrixcloud/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ async def get_user_names_by_ids(self, user_ids):
)
return await cursor.to_list(length=1000)

async def get_user_by_id(self, user_id: uuid.UUID):
"""return user from user_id"""
return await self.user_db.get(user_id)

async def get_superuser(self):
"""return current superuser, if any"""
return await self.user_db.collection.find_one({"is_superuser": True})
Expand Down

0 comments on commit 748c867

Please sign in to comment.