Content-Length: 226733 | pFad | http://github.com/tgbot-collection/SearchGram/commit/e33743b3b20945ffa506b789ba00fc7d2959d80f

FD add tqdm · tgbot-collection/SearchGram@e33743b · GitHub
Skip to content

Commit

Permalink
add tqdm
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed May 13, 2023
1 parent 4427b30 commit e33743b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions searchgram/add_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import time

from tqdm import tqdm

from engine import SearchEngine

logging.basicConfig(level=logging.INFO)
Expand All @@ -17,18 +19,20 @@ def convert_to_timestamp(date: str) -> int:
return int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S")))


limit = 20
limit = 100
offset = 0
index = s.client.index("telegram")
total_documents = index.get_stats().number_of_documents

for offset in range(0, total_documents, limit):
documents = index.get_documents({"limit": limit, "offset": offset}).results
for res in documents:
date_string = res.date
timestamp = convert_to_timestamp(date_string)
ID = res.ID
uid = s.client.index("telegram").update_documents({"ID": ID, "timestamp": timestamp})
logging.info("Updated %s - %s", res.ID, uid.task_uid)
logging.info("Starting to add timestamp to documents")

with tqdm(total=total_documents) as pbar:
for offset in range(0, total_documents, limit):
documents = index.get_documents({"limit": limit, "offset": offset}).results
for res in documents:
date_string = res.date
timestamp = convert_to_timestamp(date_string)
uid = s.client.index("telegram").update_documents({"ID": (res.ID), "timestamp": timestamp})
pbar.update(1)

logging.info("Done")

0 comments on commit e33743b

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tgbot-collection/SearchGram/commit/e33743b3b20945ffa506b789ba00fc7d2959d80f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy