Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data rearchitecture] Improve logs during course updates #6149

Prev Previous commit
Next Next commit
Pass in update_service to UpdateCourseWikiTimeslices
gabina committed Jan 21, 2025
commit fa542bb5594ab21e7f9565638111e7078d1c0831
5 changes: 3 additions & 2 deletions app/services/prepare_timeslices.rb
Original file line number Diff line number Diff line change
@@ -4,10 +4,11 @@
# Ensures that the necessary timeslices are created prior to a new update
# of the course statistics.
class PrepareTimeslices
def initialize(course)
def initialize(course, update_service: nil)
@course = course
@timeslice_manager = TimesliceManager.new(@course)
@debugger = UpdateDebugger.new(@course)
@update_service = update_service
end

# Deletes all existing timeslices and recreates them from scratch.
@@ -32,7 +33,7 @@ def adjust_timeslices
end
# Execute update tasks in a specific order
UpdateTimeslicesCourseWiki.new(@course).run
UpdateTimeslicesCourseUser.new(@course).run
UpdateTimeslicesCourseUser.new(@course, update_service: @update_service).run
UpdateTimeslicesUntrackedArticle.new(@course).run
UpdateTimeslicesCourseDate.new(@course).run
UpdateTimeslicesScopedArticle.new(@course).run
2 changes: 1 addition & 1 deletion app/services/update_course_wiki_timeslices.rb
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ def run(all_time:)

def pre_update(from_scratch)
@debugger.log_update_progress :pre_update_start
prepare_timeslices = PrepareTimeslices.new(@course)
prepare_timeslices = PrepareTimeslices.new(@course, update_service: @update_service)
from_scratch ? prepare_timeslices.recreate_timeslices : prepare_timeslices.adjust_timeslices
@debugger.log_update_progress :pre_update_finish
end
5 changes: 3 additions & 2 deletions app/services/update_timeslices_course_user.rb
Original file line number Diff line number Diff line change
@@ -5,9 +5,10 @@
require_dependency "#{Rails.root}/lib/revision_data_manager"

class UpdateTimeslicesCourseUser
def initialize(course)
def initialize(course, update_service: nil)
@course = course
@timeslice_manager = TimesliceManager.new(course)
@update_sercice = update_service
end

def run
@@ -44,7 +45,7 @@ def add_user_ids(user_ids)
def fetch_users_revisions_for_wiki(wiki, user_ids)
users = User.find(user_ids)

manager = RevisionDataManager.new(wiki, @course)
manager = RevisionDataManager.new(wiki, @course, update_service: @update_service)
# Fetch the revisions for users for the complete period
revisions = manager.fetch_revision_data_for_users(users,
@course.start.strftime('%Y%m%d%H%M%S'),