<commit_before># frozen_string_literal: true
# == Schema Information
#
# Table name: program_details
#
#  id         :integer          not null, primary key
#  channel_id :integer          not null
#  work_id    :integer          not null
#  url        :string
#  started_at :datetime
#  aasm_state :string           default("published"), not null
#  created_at :datetime         not null
#  updated_at :datetime         not null
#
# Indexes
#
#  index_program_details_on_channel_id              (channel_id)
#  index_program_details_on_channel_id_and_work_id  (channel_id,work_id) UNIQUE
#  index_program_details_on_work_id                 (work_id)
#

class ProgramDetail < ApplicationRecord
  include AASM
  include DbActivityMethods

  DIFF_FIELDS = %i(channel_id work_id url started_at).freeze

  aasm do
    state :published, initial: true
    state :hidden

    event :hide do
      transitions from: :published, to: :hidden
    end
  end

  attr_accessor :time_zone

  validates :url, url: { allow_blank: true }

  belongs_to :channel
  belongs_to :work
  has_many :db_activities, as: :trackable, dependent: :destroy
  has_many :db_comments, as: :resource, dependent: :destroy

  scope :in_video_service, -> { joins(:channel).where(channels: { video_service: true }) }
<commit_msg>Touch if program details are updated<commit_after># frozen_string_literal: true
# == Schema Information
#
# Table name: program_details
#
#  id         :integer          not null, primary key
#  channel_id :integer          not null
#  work_id    :integer          not null
#  url        :string
#  started_at :datetime
#  aasm_state :string           default("published"), not null
#  created_at :datetime         not null
#  updated_at :datetime         not null
#
# Indexes
#
#  index_program_details_on_channel_id              (channel_id)
#  index_program_details_on_channel_id_and_work_id  (channel_id,work_id) UNIQUE
#  index_program_details_on_work_id                 (work_id)
#

class ProgramDetail < ApplicationRecord
  include AASM
  include DbActivityMethods

  DIFF_FIELDS = %i(channel_id work_id url started_at).freeze

  aasm do
    state :published, initial: true
    state :hidden

    event :hide do
      transitions from: :published, to: :hidden
    end
  end

  attr_accessor :time_zone

  validates :url, url: { allow_blank: true }

  belongs_to :channel
  belongs_to :work, touch: true
  has_many :db_activities, as: :trackable, dependent: :destroy
  has_many :db_comments, as: :resource, dependent: :destroy

  scope :in_video_service, -> { joins(:channel).where(channels: { video_service: true }) }

{'fraction_non_alphanumeric': 0.07957153787299158, 'fraction_numerical': 0.0, 'mean_word_length': 3.258957654723127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2733338', 'n_tokens_mistral': 832, 'n_tokens_neox': 817, 'n_words': 217}