Skip to content

Commit

Permalink
Don't search for index if unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrofelnik committed Jun 7, 2024
1 parent ba44059 commit c4c03fa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion oracles/src/repositories/web3/chat_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def _get_chat(self, i: int) -> Optional[Chat]:
async def _index_new_chats(self):
chats_count = await self.oracle_contract.functions.promptsCount().call()
self.metrics["chats_count"] = chats_count
if not self.last_chats_count:
if not self.last_chats_count and chats_count > 0:
self.last_chats_count = await self._find_first_unprocessed(
chats_count,
lambda index: self.oracle_contract.functions.isPromptProcessed(
Expand Down
2 changes: 1 addition & 1 deletion oracles/src/repositories/web3/function_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def _index_new_function_calls(self):
await self.oracle_contract.functions.functionsCount().call()
)
self.metrics["functions_count"] = function_calls_count
if not self.last_function_calls_count:
if not self.last_function_calls_count and function_calls_count > 0:
self.last_function_calls_count = await self._find_first_unprocessed(
function_calls_count,
lambda index: self.oracle_contract.functions.isFunctionProcessed(
Expand Down
4 changes: 2 additions & 2 deletions oracles/src/repositories/web3/knowledge_base_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def _index_new_kb_index_requests(self):
await self.oracle_contract.functions.kbIndexingRequestCount().call()
)
self.metrics["knowledgebase_index_count"] = kb_index_request_count
if not self.last_kb_index_request_count:
if not self.last_kb_index_request_count and kb_index_request_count > 0:
self.last_kb_index_request_count = await self._find_first_unprocessed(
kb_index_request_count,
lambda index: self.oracle_contract.functions.isKbIndexingRequestProcessed(
Expand Down Expand Up @@ -185,7 +185,7 @@ async def _get_kb_query(self, i: int) -> Optional[KnowledgeBaseQuery]:
async def _index_new_kb_queries(self):
kb_query_count = await self.oracle_contract.functions.kbQueryCount().call()
self.metrics["knowledgebase_query_count"] = kb_query_count
if not self.last_kb_query_count:
if not self.last_kb_query_count and kb_query_count > 0:
self.last_kb_query_count = await self._find_first_unprocessed(
kb_query_count,
lambda index: self.oracle_contract.functions.isKbQueryProcessed(
Expand Down

0 comments on commit c4c03fa

Please sign in to comment.