-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stats add new stats visibility column to user groups (#4210)
* add stats_visibility enum and backfill rake task for user_groups * remove detected trialing whitespace for usergroups backfill rake task * Update 20230613165746_add_stats_visibility_to_user_groups.rb * adding comments on stats visibility levels * update wording of comment on stats_visbility * update user group enum to take care of the case where we want to show aggregate stats publicly but only members can view individual stats (vs the case where only admins can view individual stats) * update user_group.rb stats_visibilty docs without trailing whitespace * update comments on stats visibilty levels
- Loading branch information
1 parent
d36cdd2
commit 82762e7
Showing
4 changed files
with
44 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
db/migrate/20230613165746_add_stats_visibility_to_user_groups.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddStatsVisibilityToUserGroups < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :user_groups, :stats_visibility, :integer | ||
# defaulting to private_agg_only stats_visibility view (where members can view aggregate stats but only admins can view detailed stats) | ||
change_column_default :user_groups, :stats_visibility, from: nil, to: 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :user_groups do | ||
desc 'Backfill stats_visibility column default in batches' | ||
task backfill_stats_visibility_column_default: :environment do | ||
UserGroup.where(stats_visibility: nil).select(:id).find_in_batches do |user_group| | ||
user_group_ids_to_update = user_group.map(&:id) | ||
UserGroup.where(id: user_group_ids_to_update).update_all(stats_visibility: 0) | ||
end | ||
end | ||
end |