-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1524 from codidact/cellio/1248-generalize-profile…
…-links generalize profile links
- Loading branch information
Showing
19 changed files
with
347 additions
and
67 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
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
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,6 @@ | ||
class UserWebsite < ApplicationRecord | ||
belongs_to :user | ||
default_scope { order(:position) } | ||
|
||
MAX_ROWS = 3 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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 |
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
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 @@ | ||
class CreateUserWebsites < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :user_websites do |t| | ||
t.column :label, :string, limit:80 | ||
t.string :url | ||
t.integer :position | ||
end | ||
add_reference :user_websites, :user, null: false, foreign_key: true | ||
add_index(:user_websites, [:user_id, :url], unique: true) | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
db/migrate/20250128030354_create_maintenance_tasks_runs.maintenance_tasks.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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from maintenance_tasks (originally 20201211151756) | ||
class CreateMaintenanceTasksRuns < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table(:maintenance_tasks_runs) do |t| | ||
t.string(:task_name, null: false) | ||
t.datetime(:started_at) | ||
t.datetime(:ended_at) | ||
t.float(:time_running, default: 0.0, null: false) | ||
t.integer(:tick_count, default: 0, null: false) | ||
t.integer(:tick_total) | ||
t.string(:job_id) | ||
t.bigint(:cursor) | ||
t.string(:status, default: :enqueued, null: false) | ||
t.string(:error_class) | ||
t.string(:error_message) | ||
t.text(:backtrace) | ||
t.timestamps | ||
t.index(:task_name) | ||
t.index([:task_name, :created_at], order: { created_at: :desc }) | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
db/migrate/20250128030355_change_cursor_to_string.maintenance_tasks.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from maintenance_tasks (originally 20210219212931) | ||
class ChangeCursorToString < ActiveRecord::Migration[6.0] | ||
# This migration will clear all existing data in the cursor column with MySQL. | ||
# Ensure no Tasks are paused when this migration is deployed, or they will be resumed from the start. | ||
# Running tasks are able to gracefully handle this change, even if interrupted. | ||
def up | ||
change_table(:maintenance_tasks_runs) do |t| | ||
t.change(:cursor, :string) | ||
end | ||
end | ||
|
||
def down | ||
change_table(:maintenance_tasks_runs) do |t| | ||
t.change(:cursor, :bigint) | ||
end | ||
end | ||
end |
Oops, something went wrong.