SCI-3119 schedule the creaton of template

This commit is contained in:
Miha Mencin 2019-03-01 17:47:04 +01:00
parent b501327c87
commit 844303ae7c
3 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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' },

View file

@ -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