Skip to content

Commit

Permalink
fixed an issue when user only had one post
Browse files Browse the repository at this point in the history
  • Loading branch information
Allexio committed Mar 26, 2021
1 parent 0e419ea commit f6de4a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/parser_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def parse_posts(user_data: dict) -> dict:
posts_path = getcwd() + "/temp/posts/your_posts_1.json"
post_list = utils.json_file_converter(posts_path)
post_total = len(post_list)

if not isinstance(post_list, list):
user_data["nbr_of_posts"] = "1"
user_data["monthly_posts"] = str(posts_per_month)
return user_data

for post in post_list:
post_timestamp = post["timestamp"]
post_month, post_year = utils.epoch_to_year_and_month(post_timestamp)
Expand All @@ -24,5 +30,3 @@ def parse_posts(user_data: dict) -> dict:
user_data["monthly_posts"] = str(monthly_post_list)

return user_data


0 comments on commit f6de4a7

Please sign in to comment.