Skip to content

Commit

Permalink
fix: [chat forum] fix get years daterange
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Dec 23, 2024
1 parent e19595d commit 66de987
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/lib/objects/abstract_chat_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,17 @@ def get_nb_week_messages(self):
return stats

def get_message_years(self):
try:
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_first_message()))
timestamp = self.get_timestamp_first_message()
if not timestamp:
year_start = int(self.get_first_seen()[0:4])
year_end = int(self.get_last_seen()[0:4])
return list(range(year_start, year_end + 1))
else:
timestamp = datetime.utcfromtimestamp(float(timestamp))
year_start = int(timestamp.strftime('%Y'))
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_last_message()))
year_end = int(timestamp.strftime('%Y'))
return list(range(year_start, year_end + 1))
except:
return []

def get_nb_year_messages(self, year):
nb_year = {}
Expand Down

0 comments on commit 66de987

Please sign in to comment.