Add tqdm progress bar

This commit is contained in:
KnugiHK
2026-01-19 20:49:14 +08:00
parent 908d8f71ca
commit 8058ed8219

View File

@@ -498,7 +498,8 @@ def _format_message_text(text):
def _get_reactions(db, data):
"""
Process message reactions.
Process message reactions. Only new schema is supported.
Chat filter is not applied here at the moment. Maybe in the future.
"""
c = db.cursor()
@@ -531,8 +532,11 @@ def _get_reactions(db, data):
logger.warning(f"Could not fetch reactions (schema might be too old or incompatible){CLEAR_LINE}")
return
row = c.fetchone()
while row is not None:
rows = c.fetchall()
total_row_number = len(rows)
with tqdm(total=total_row_number, desc="Processing reactions", unit="reaction", leave=False) as pbar:
for row in rows:
parent_id = row["parent_message_row_id"]
reaction = row["reaction"]
chat_id = row["chat_jid_raw"]
@@ -557,9 +561,9 @@ def _get_reactions(db, data):
sender_name = "Unknown"
message.reactions[sender_name] = reaction
row = c.fetchone()
logger.info(f"Processed reactions{CLEAR_LINE}")
pbar.update(1)
total_time = pbar.format_dict['elapsed']
logger.info(f"Processed {total_row_number} reactions in {convert_time_unit(total_time)}{CLEAR_LINE}")
def media(db, data, media_folder, filter_date, filter_chat, filter_empty, separate_media=True, fix_dot_files=False):