clean up notification

This commit is contained in:
simon 2023-03-16 18:11:08 +07:00
parent 461c2c4600
commit e6da63ff09
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 5 additions and 8 deletions

View File

@ -152,7 +152,7 @@ class IndexPaginate:
if self.kwargs.get("callback"):
self.kwargs.get("callback")(all_hits, self.index_name).run()
if counter % 10 == 0 and self.kwargs.get("task"):
if self.kwargs.get("task"):
print(f"{self.index_name}: processing page {counter}")
self._notify(len(all_results))
@ -167,12 +167,9 @@ class IndexPaginate:
"""send notification on task"""
total = self.kwargs.get("total")
progress = (processed + 1) / total
message = f"Processing {self.index_name} {processed}/{total}"
print(message)
self.kwargs.get("task").send_progress(
message_lines=[message],
progress=progress,
)
index_clean = self.index_name.lstrip("ta_").title()
message = [f"Processing {index_clean}s {processed}/{total}"]
self.kwargs.get("task").send_progress(message, progress=progress)
def clean_pit(self):
"""delete pit from elastic search"""

View File

@ -248,7 +248,7 @@ class Reindex(ReindexBase):
"""send notification back to task"""
remaining = RedisQueue(index_config["queue_name"]).length()
idx = total - remaining
message = [f"Reindexing {name[0].upper()}{name[1:]}s {idx}/{total}"]
message = [f"Reindexing {name[0].title()}s {idx}/{total}"]
progress = idx / total
self.task.send_progress(message, progress=progress)