From 319d76eed02d447681261fa519ab423f8707017f Mon Sep 17 00:00:00 2001 From: Navin Nair K Date: Sun, 26 May 2019 14:23:18 +0530 Subject: [PATCH 1/3] locked carrierwave version to fix version related issues --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7bceea3..4fd6e4b 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ gem "therubyracer" gem "foundation-rails",'5.2.1.0' gem 'hirb' gem 'thin' -gem 'carrierwave' +gem 'carrierwave', '1.0' gem "mini_magick" gem "select2-rails", '3.5.4' #gem "cancan" From b7126b734e5bcfeecfe800263203f83a558dc481 Mon Sep 17 00:00:00 2001 From: Navin Nair K Date: Mon, 27 May 2019 01:42:25 +0530 Subject: [PATCH 2/3] fixed: Removing members from team does not decrement member count --- app/controllers/users_controller.rb | 7 +------ app/models/project.rb | 2 +- app/models/team_member.rb | 4 ++-- app/models/user.rb | 9 +++++++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 31edbf7..59f60ae 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -67,12 +67,7 @@ def update # DELETE /users/1 # DELETE /users/1.json def destroy - if @user.update_attribute(:is_deleted, true) - @user.project_managers.update_all(:status => 'archived') - @user.team_members.update_all(:status => 'archived') - @user.reporting_managers.update_all(:status => 'archived') - @user.reporting_employees.update_all(:status => 'archived') - end + @user.archive_user respond_to do |format| format.html { redirect_to users_url } format.json { head :no_content } diff --git a/app/models/project.rb b/app/models/project.rb index 608bc99..6b45e21 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -5,7 +5,7 @@ class Project < ActiveRecord::Base has_many :project_managers has_many :users,:through=>:project_managers,:after_remove => :update_user_project_count has_many :team_members, :through => :teams - has_many :project_members, :through=>:team_members, :source=>:user + has_many :project_members, -> { uniq }, :through => :team_members, :source => :user scope :active, -> {where(is_deleted: false)} validates_presence_of :name, :code diff --git a/app/models/team_member.rb b/app/models/team_member.rb index 6e56795..1c5413a 100644 --- a/app/models/team_member.rb +++ b/app/models/team_member.rb @@ -8,7 +8,7 @@ class TeamMember < ActiveRecord::Base def update_member_counts user.update_attributes(:admin_teams_count=>user.admin_teams.count) if self.role == 'lead' - team.update_attributes(:members_count=>team.users.active.count,:managers_count=>team.team_leads.active.count) - team.project.update_attributes(:member_count=>team.project.project_members.active.count) + team.update_attributes(:members_count=>team.members.count,:managers_count=>team.team_leads.active.count) + team.project.update_attribute(:member_count, team.project.project_members.active.count) end end diff --git a/app/models/user.rb b/app/models/user.rb index 7a4a1d6..1463176 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -110,5 +110,14 @@ def ensure_manager_exists end end end + + def archive_user + if self.update_attribute(:is_deleted, true) + project_managers.update_all(:status => 'archived') + team_members.each{|tm| tm.update_attribute(:status, 'archived')} + reporting_managers.update_all(:status => 'archived') + reporting_employees.update_all(:status => 'archived') + end + end end From 53994c2b0cfe6eeb89dfc9b388f487f56c04158a Mon Sep 17 00:00:00 2001 From: Navin Nair K Date: Mon, 27 May 2019 01:59:57 +0530 Subject: [PATCH 3/3] fixed: showing duplicate teams under user profile --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1463176..506a70b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base has_many :project_managers has_many :projects, :through => :project_managers has_many :team_members - has_many :teams, :through => :team_members + has_many :teams, -> { uniq }, :through => :team_members has_many :admin_teams, :through => :projects, :source => :teams has_many :leads, -> { where role: 'lead' }, class_name: 'TeamMember' has_many :admin_teams, :through => :leads, :source => :team #,:foreign_key=>'user_id'