mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
Add raw_data to heartbeats
This commit is contained in:
@@ -67,7 +67,8 @@ class MigrateUserFromHackatimeJob < ApplicationJob
|
||||
cursorpos: heartbeat.cursor_position,
|
||||
project_root_count: heartbeat.project_root_count,
|
||||
is_write: heartbeat.is_write,
|
||||
source_type: :wakapi_import
|
||||
source_type: :wakapi_import,
|
||||
raw_data: heartbeat.attributes.slice(*Heartbeat.indexed_attributes)
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Heartbeat < ApplicationRecord
|
||||
before_save :set_fields_hash!
|
||||
before_save :set_raw_data!
|
||||
|
||||
include Heartbeatable
|
||||
include TimeRangeFilterable
|
||||
@@ -107,8 +108,8 @@ class Heartbeat < ApplicationRecord
|
||||
%w[user_id branch category dependencies editor entity language machine operating_system project type user_agent line_additions line_deletions lineno lines cursorpos project_root_count time is_write]
|
||||
end
|
||||
|
||||
def set_raw_data
|
||||
self.raw_data = self.attributes.slice(*self.class.indexed_attributes)
|
||||
def set_raw_data!
|
||||
self.raw_data ||= self.attributes.slice(*self.class.indexed_attributes)
|
||||
end
|
||||
|
||||
def soft_delete
|
||||
|
||||
5
db/migrate/20250509160228_add_raw_data_to_heartbeats.rb
Normal file
5
db/migrate/20250509160228_add_raw_data_to_heartbeats.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddRawDataToHeartbeats < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :heartbeats, :raw_data, :jsonb
|
||||
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_07_211848) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_05_09_160228) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@@ -208,6 +208,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_07_211848) do
|
||||
t.inet "ip_address"
|
||||
t.integer "ysws_program", default: 0, null: false
|
||||
t.datetime "deleted_at"
|
||||
t.jsonb "raw_data"
|
||||
t.index ["category", "time"], name: "index_heartbeats_on_category_and_time"
|
||||
t.index ["fields_hash"], name: "index_heartbeats_on_fields_hash_when_not_deleted", unique: true, where: "(deleted_at IS NULL)"
|
||||
t.index ["user_id", "time"], name: "idx_heartbeats_user_time_active", where: "(deleted_at IS NULL)"
|
||||
|
||||
Reference in New Issue
Block a user