Opt: Reduce ocr in goto_entry

This commit is contained in:
Zebartin 2023-09-26 23:11:45 +08:00
parent 818b196e45
commit c033d3b60d
2 changed files with 9 additions and 4 deletions

View File

@ -132,16 +132,18 @@ class Assignment(AssignmentClaim, SynthesizeUI):
return remain
for group in self._iter_groups():
self.goto_group(group)
insight = False
for assignment in self._iter_entries():
if assignment in self.dispatched:
continue
logger.hr('Assignment all', level=2)
logger.info(f'Check assignment all: {assignment}')
self.goto_entry(assignment)
self.goto_entry(assignment, insight)
status = self._check_assignment_status()
if status == AssignmentStatus.CLAIMABLE:
self.claim(assignment, None, should_redispatch=False)
remain += 1
insight = True # Order of entries change after claiming
continue
if status == AssignmentStatus.DISPATCHED:
self.dispatched[assignment] = datetime.now() + \
@ -191,12 +193,14 @@ class Assignment(AssignmentClaim, SynthesizeUI):
if not isinstance(group, AssignmentEventGroup):
continue
self.goto_group(group)
insight = False
for assignment in self._iter_entries():
if assignment in self.dispatched:
continue
logger.hr('Assignment event', level=2)
logger.info(f'Check assignment event: {assignment}')
self.goto_entry(assignment)
self.goto_entry(assignment, insight)
insight = True
status = self._check_assignment_status()
# Should only be dispatchable or locked after _check_all
if status == AssignmentStatus.DISPATCHABLE:

View File

@ -140,10 +140,11 @@ class AssignmentUI(UI):
if ASSIGNMENT_GROUP_SWITCH.set(group, self):
self._wait_until_entry_loaded()
def goto_entry(self, entry: AssignmentEntry):
def goto_entry(self, entry: AssignmentEntry, insight: bool = True):
"""
Args:
entry (AssignmentEntry):
insight (bool): skip ocr to save time if insight is False
Examples:
self = AssignmentUI('src')
@ -160,7 +161,7 @@ class AssignmentUI(UI):
raise ScriptError(err_msg)
else:
self.goto_group(entry.group)
ASSIGNMENT_ENTRY_LIST.select_row(entry, self)
ASSIGNMENT_ENTRY_LIST.select_row(entry, self, insight=insight)
def _wait_until_group_loaded(self):
skip_first_screenshot = True