Skip to content

Commit

Permalink
finish up #50
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Vogt committed Oct 28, 2020
1 parent 17452f9 commit 2ec2671
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion moodle_dl/moodle_connector/moodle_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def fetch_state(self) -> [Course]:

forums = forums_handler.fetch_forums(courses)
if download_forums:
last_timestamps_per_forum = {942115: 1595849253}
last_timestamps_per_forum = self.recorder.get_last_timestamps_per_forum()
forums = forums_handler.fetch_forums_posts(forums, last_timestamps_per_forum)

index = 0
Expand Down
23 changes: 23 additions & 0 deletions moodle_dl/state_recorder/state_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,29 @@ def changes_of_new_version(self, current_courses: [Course]) -> [Course]:

return changed_courses

def get_last_timestamps_per_forum(self) -> {}:
"""Returns a dict of timestamps per forum cmid"""

conn = sqlite3.connect(self.db_file)
conn.row_factory = sqlite3.Row
cursor = conn.cursor()
result_dict = {}

cursor.execute(
"""SELECT module_id, max(content_timemodified) as content_timemodified
FROM files WHERE module_modname = 'forum' AND content_type = 'description'
GROUP BY module_id;"""
)

curse_rows = cursor.fetchall()

for course_row in curse_rows:
result_dict[course_row['module_id']] = course_row['content_timemodified']

conn.close()

return result_dict

def changes_to_notify(self) -> [Course]:
changed_courses = []

Expand Down

0 comments on commit 2ec2671

Please sign in to comment.