-
Notifications
You must be signed in to change notification settings - Fork 166
LG-16404: Tmx impacted users cleanup #12330
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2519f95
Internal, Account creation, tmx account creation rake task to unsuspe…
mdiarra3 aff3ea4
changelog: Internal, TMX, device profiling rake task fix users
mdiarra3 7d1f6ef
update profiling
mdiarra3 99f3038
update rake task
mdiarra3 f0854d5
added notes section
mdiarra3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
db/primary_migrate/20250714184424_add_notes_to_device_profiling_result.rb
This file contains hidden or 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 @@ | ||
| class AddNotesToDeviceProfilingResult < ActiveRecord::Migration[8.0] | ||
| def up | ||
| add_column :device_profiling_results, :notes, :string, comment: 'sensitive=false' | ||
| end | ||
|
|
||
| def down | ||
| remove_column :device_profiling_results, :notes | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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,79 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| namespace :device_profiling do | ||
| desc 'Approve rejected device profiling results to pass for list of UUIDs' | ||
| task :approve_rejected_users, [:user_uuids] => :environment do |_task, _args| | ||
| user_uuids = ARGV[1] | ||
|
|
||
| if user_uuids.blank? | ||
| puts 'Error: user_uuids is required' | ||
| exit 1 | ||
| end | ||
|
|
||
| # Parse UUIDs | ||
| uuid_list = user_uuids.split(',').map(&:strip).reject(&:blank?) | ||
|
|
||
| puts "Processing #{uuid_list.count} user UUID(s)" | ||
| puts "Action: Change 'reject' to 'pass' (skip if already 'pass')" | ||
| puts '' | ||
|
|
||
| total_users_processed = 0 | ||
| total_results_updated = 0 | ||
| skipped_already_passed = 0 | ||
| users_with_no_results = 0 | ||
|
|
||
| uuid_list.each do |user_uuid| | ||
| total_users_processed += 1 | ||
|
|
||
| begin | ||
| # Find user by UUID | ||
| user = User.find_by(uuid: user_uuid) | ||
| if user.blank? | ||
| puts "User not found: #{user_uuid}" | ||
| next | ||
| end | ||
|
|
||
| # Find device profiling results for this user (reject or pass) | ||
| result = DeviceProfilingResult.where( | ||
| user_id: user.id, | ||
| profiling_type: DeviceProfilingResult::PROFILING_TYPES[:account_creation], | ||
| ).first | ||
|
|
||
| if result.nil? | ||
| users_with_no_results += 1 | ||
| puts "No device profiling results found for: #{user_uuid} (#{user.email})" | ||
| next | ||
| end | ||
|
|
||
| # Check if already passed | ||
|
|
||
| if result.review_status == 'pass' | ||
| skipped_already_passed += 1 | ||
| puts "Already passed: #{user_uuid}" | ||
| next | ||
| end | ||
|
|
||
| # Update rejected results to pass | ||
| puts "Updating rejected result for: #{user_uuid}" | ||
| result.update!(review_status: 'pass', notes: 'Manually overridden') | ||
| total_results_updated += 1 | ||
|
|
||
| puts "Successfully updated result for: #{user_uuid}" | ||
|
|
||
| # Log for audit | ||
| rescue => e | ||
| puts "Error processing #{user_uuid}: #{e.message}" | ||
| end | ||
| end | ||
|
|
||
| puts '' | ||
| puts '=' * 80 | ||
| puts 'SUMMARY:' | ||
| puts "Total users processed: #{total_users_processed}" | ||
| puts "Results updated (reject → pass): #{total_results_updated}" | ||
| puts "Users already passed: #{skipped_already_passed}" | ||
| puts "Users with no results: #{users_with_no_results}" | ||
|
|
||
| puts 'Task completed successfully!' | ||
| end | ||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand this. Is change/reject somehow associated with the uuids?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes its where we are changing the TMX device profile object from reject to pass since it was wrongly flagged as a reject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This action is just listing what will be happening throughout the script.