mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
Add slack neighborhood channel into db
This commit is contained in:
10
app/jobs/one_time/set_neighborhood_channels_job.rb
Normal file
10
app/jobs/one_time/set_neighborhood_channels_job.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class OneTime::SetNeighborhoodChannelsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
User.where.not(slack_uid: nil).find_each(batch_size: 100) do |user|
|
||||
user.set_neighborhood_channel
|
||||
user.save! if user.changed?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,6 +47,12 @@ class User < ApplicationRecord
|
||||
).order(created_at: :desc).limit(10).all
|
||||
end
|
||||
|
||||
def set_neighborhood_channel
|
||||
return unless slack_uid.present?
|
||||
|
||||
self.slack_neighborhood_channel = SlackNeighborhood.find_by_id(slack_uid)
|
||||
end
|
||||
|
||||
def format_extension_text(duration)
|
||||
case hackatime_extension_text_type
|
||||
when "simple_text"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSlackNeighborhoodChannelToUsers < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :users, :slack_neighborhood_channel, :string, null: true
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_05_152654) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_06_155521) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@@ -307,6 +307,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_05_152654) do
|
||||
t.text "github_access_token"
|
||||
t.string "github_username"
|
||||
t.string "slack_username"
|
||||
t.string "slack_neighborhood_channel"
|
||||
t.index ["slack_uid"], name: "index_users_on_slack_uid", unique: true
|
||||
t.index ["timezone"], name: "index_users_on_timezone"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user