mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-20 20:14:45 +08:00
SCI-3119 schedule the creaton of template
This commit is contained in:
parent
b501327c87
commit
844303ae7c
3 changed files with 13 additions and 0 deletions
|
@ -47,6 +47,7 @@ class Users::SessionsController < Devise::SessionsController
|
|||
|
||||
def after_sign_in
|
||||
flash[:system_notification_modal] = true
|
||||
TemplatesService.new.schedule_creation_for_user(current_user)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -41,6 +41,8 @@ class Team < ApplicationRecord
|
|||
attr_accessor :without_intro_demo
|
||||
after_create :generate_intro_demo
|
||||
|
||||
scope :without_templates, -> { includes(:projects).where("projects.template": nil) }
|
||||
|
||||
def default_view_state
|
||||
{ 'projects' =>
|
||||
{ 'cards' => { 'sort' => 'new' },
|
||||
|
|
|
@ -55,4 +55,14 @@ class TemplatesService
|
|||
end
|
||||
[updated_counter, processed_counter]
|
||||
end
|
||||
|
||||
def schedule_creation_for_user(user)
|
||||
user.teams.each do |team|
|
||||
unless team.projects.where(template: true).any?
|
||||
TemplatesService.new.delay(
|
||||
queue: :templates
|
||||
).update_team(team)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue