فهرست منبع

Get institutes instead of reading

JoostSijm 6 سال پیش
والد
کامیت
955135c3d4
2فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 1 0
      app/__main__.py
  2. 10 3
      app/api.py

+ 1 - 0
app/__main__.py

@@ -49,6 +49,7 @@ def job_send_progress_message(state_id, department_type, language):
     LOGGER.info('"%s": Send progress message for "%s" department', state_id, department_type)
     yesterday_professors = get_yesterday_professors(state_id, department_type)
     if not yesterday_professors:
+        LOGGER.warning('"%s": 0 professor yesterday in "%s" department', state_id, department_type)
         return
     yesterday_total = 0
     for professor in yesterday_professors:

+ 10 - 3
app/api.py

@@ -65,9 +65,16 @@ def parse_department(html):
 
 def get_institutes():
     """Get all institutes"""
-    # institutes = download_institutes()
-    institutes = read_institutes()
-    return institutes
+    # return read_institutes()
+    return download_institutes()
+
+def download_institutes():
+    """Download the department"""
+    response = requests.get(
+        '{}listed/institutes'.format(BASE_URL),
+        headers=HEADERS
+    )
+    return parse_institutes(response.text)
 
 def read_institutes():
     """Read from department file"""