Skip to content

Commit f43995f

Browse files
committed
Twitter Bot: Fix the previous date method
1 parent 0e069e1 commit f43995f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tg_bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ def display_tweet(self, context):
5050

5151
# the previous date from which the tweets need to be sent
5252
previous_date = self.tw_bot.nawab_find_prev_date()
53+
previous_datetime = datetime(previous_date.year, previous_date.month, previous_date.day)
5354
tid = pd.read_csv(self.dirpath + 'tid_store.csv')
5455
tid['Date_time'] = pd.to_datetime(tid['Date_time'])
5556

5657
for index, tid_store in tid[::-1].iterrows():
5758
scrape_date = tid_store['Date_time']
58-
if scrape_date < previous_date:
59+
if scrape_date <= previous_datetime:
5960
break
6061
try:
6162
u = self.twitter_api.get_status(id=tid_store['Id'])

twitter_bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ def nawab_find_prev_date(self):
9090
"""to find the previous date in the tid"""
9191
tid = pd.read_csv(self.dirpath + 'tid_store.csv')
9292
tid["Date_time"]= pd.to_datetime(tid["Date_time"])
93-
previous_date = tid['Date_time'].iloc[-1]
93+
previous_datetime = tid['Date_time'].iloc[-1]
9494
#find the previous date by iterating tid_store bottom-up
9595
for index, tid_store in tid[::-1].iterrows():
9696
scrape_datetime = tid_store['Date_time']
9797
scrape_date = date(scrape_datetime.year, scrape_datetime.month, scrape_datetime.day)
98+
previous_date = date(previous_datetime.year, previous_datetime.month, previous_datetime.day)
9899
if scrape_date!=previous_date:
99100
previous_date = scrape_date
100101
break

0 commit comments

Comments
 (0)