Skip to content
Snippets Groups Projects
Select Git revision
  • 313eed9380f7628caaefc4165b0a60fe68d00a0e
  • eip-develop default
  • develop
  • 0valt/assorted
  • master
  • 0valt/flag-sort
  • 0valt/rlyeh
  • art/versioned-error-logs
  • 0valt/csrf
  • dependabot/bundler/bundler-6d4d941ed1
  • dependabot/npm_and_yarn/npm_and_yarn-a48ea45f8c
  • 0valt/caching
  • art/mod-spam-tools
  • 0valt/keyboard
  • 0valt/1808/unnecessary-ajax
  • 0valt/general-fixes
  • 0valt/tour-fixes
  • 0valt/1815/tags-ordering
  • 0valt/voting-improvements
  • 0valt/1459/draft-discard
  • 0valt/1790/preferences
  • 0valt/query-optimizations
  • v0.12.3
  • v0.12.2
  • v0.12.1
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
  • v0.6.1
  • v0.6.0
  • v0.5.0
  • v0.4.0
  • v0.3.0
  • v1.0
37 results

initialize_user_websites_task.rb

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    initialize_user_websites_task.rb 996 B
    # frozen_string_literal: true
    
    module Maintenance
      class InitializeUserWebsitesTask < MaintenanceTasks::Task
        def collection
          User.all
        end
    
        def process(user)
          unless user.user_websites.exists?(position: 1)
            if user.website.present?
              UserWebsite.create!(user_id: user.id, position: 1, label: 'website', url: user.website)
            else
              UserWebsite.create!(user_id: user.id, position: 1)
            end
          end
    
          unless user.user_websites.exists?(position: 2)
            if user.twitter.present?
              UserWebsite.create!(user_id: user.id, position: 2, label: 'Twitter',
                                  url: "https://twitter.com/#{user.twitter}")
            else
              UserWebsite.create!(user_id: user.id, position: 2)
            end
          end
    
          # This check *should* be superfluous, but just in case...
          unless user.user_websites.exists?(position: 3)
            UserWebsite.create!(user_id: user.id, position: 3)
          end
        end
      end
    end