Skip to content

Commit b0f828e

Browse files
newstlerclaude
andauthored
Fix UpdateGithubDataJob email validation failures (#138)
* fix(jobs): allow blank email on users, remove unused NotifyAdminJob UpdateGithubDataJob was failing for ~50% of users because GitHub's GraphQL API returns nil for private emails, triggering the email presence validation. Relaxed to allow_blank since this is OAuth-only. Removed NotifyAdminJob, AdminMailer, and associated views as they were unused beyond logging (which the job already does). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(db): remove unique constraint on users.email Multiple GitHub users have nil/blank emails (private email setting). The database-level UNIQUE index caused SQLite3::ConstraintException for these users during batch updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9ff03f1 commit b0f828e

9 files changed

Lines changed: 9 additions & 71 deletions

app/jobs/notify_admin_job.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/jobs/update_github_data_job.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,5 @@ def perform
3030
if all_errors.any?
3131
Rails.logger.warn "Errors encountered: #{all_errors.first(10).join(', ')}#{all_errors.size > 10 ? '...' : ''}"
3232
end
33-
34-
# Notify admin if there were significant failures
35-
if total_failed > 5 && defined?(NotifyAdminJob)
36-
NotifyAdminJob.perform_later(
37-
subject: "GitHub Data Update Report",
38-
message: "GitHub data update completed with #{total_failed} failures out of #{total_updated + total_failed} total users."
39-
)
40-
end
4133
end
4234
end

app/mailers/admin_mailer.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/models/post.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def create_slug_history
9898
def auto_hide_if_needed!
9999
if reports_count >= 3
100100
update!(needs_admin_review: true, published: false)
101-
NotifyAdminJob.perform_later(self)
102101
end
103102
end
104103

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class User < ApplicationRecord
3232
validates :github_id, presence: true, uniqueness: true
3333
validates :username, presence: true, uniqueness: true
3434
validates :slug, uniqueness: true, allow_blank: true
35-
validates :email, presence: true, uniqueness: true
35+
validates :email, uniqueness: true, allow_blank: true
3636

3737
# Scopes
3838
scope :trusted, -> {

app/views/admin_mailer/post_hidden_notification.html.erb

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/views/admin_mailer/post_hidden_notification.text.erb

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class RemoveUniqueIndexOnUsersEmail < ActiveRecord::Migration[8.2]
2+
def change
3+
remove_index :users, :email, unique: true
4+
add_index :users, :email
5+
end
6+
end

db/schema.rb

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)