Browse Source

Fix dashboard news feed

Arnaud Vergnet 3 years ago
parent
commit
77c4bb01d8
2 changed files with 4 additions and 9 deletions
  1. 1
    6
      dashboard/dashboard_handler.py
  2. 3
    3
      facebook/facebook_handler.py

+ 1
- 6
dashboard/dashboard_handler.py View File

@@ -30,12 +30,7 @@ def get_news_feed():
30 30
         print("Waiting for Facebook lock")
31 31
     try:
32 32
         with open(FACEBOOK_FILE) as f:
33
-            data = json.load(f)
34
-            if 'data' in data and len(data['data']) > 15:
35
-                del data['data'][14:]
36
-            else:
37
-                data = {'data': []}
38
-            return data
33
+            return json.load(f)
39 34
     except FileNotFoundError:
40 35
         print("Could not find " + FACEBOOK_FILE)
41 36
         return {'data': []}

+ 3
- 3
facebook/facebook_handler.py View File

@@ -9,9 +9,9 @@ def scrape_data():
9 9
     for post in facebook_scraper.get_posts('amicale.deseleves', pages=3):
10 10
         print(post)
11 11
         cleaned_post = {
12
-            "post_id": post["post_id"],
13
-            "post_text": post["post_text"],
14
-            "post_url": post["post_url"],
12
+            "id": post["post_id"],
13
+            "message": post["post_text"],
14
+            "url": post["post_url"],
15 15
             "image": post["image"],
16 16
             "video": post["video"],
17 17
             "link": post["link"],

Loading…
Cancel
Save