Add annual reports for accounts (#28693)
This commit is contained in:
parent
01ce9df880
commit
5b1eb09d54
21 changed files with 480 additions and 1 deletions
37
app/models/generated_annual_report.rb
Normal file
37
app/models/generated_annual_report.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: generated_annual_reports
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# year :integer not null
|
||||
# data :jsonb not null
|
||||
# schema_version :integer not null
|
||||
# viewed_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class GeneratedAnnualReport < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
scope :pending, -> { where(viewed_at: nil) }
|
||||
|
||||
def viewed?
|
||||
viewed_at.present?
|
||||
end
|
||||
|
||||
def view!
|
||||
update!(viewed_at: Time.now.utc)
|
||||
end
|
||||
|
||||
def account_ids
|
||||
data['most_reblogged_accounts'].pluck('account_id') + data['commonly_interacted_with_accounts'].pluck('account_id')
|
||||
end
|
||||
|
||||
def status_ids
|
||||
data['top_statuses'].values
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue