# frozen_string_literal: true # == Schema Information # # Table name: user_statistics # # id :integer not null, primary key # comments_posted :integer default(0), not null # day :integer default(0), not null # forum_posts :integer default(0), not null # metadata_updates :integer default(0), not null # posts_favorited :integer default(0), not null # uploads :integer default(0), not null # votes_cast :integer default(0), not null # user_id :integer not null # # Indexes # # index_user_statistics_on_user_id (user_id) # # Foreign Keys # # fk_rails_... (user_id => users.id) ON DELETE => cascade ON UPDATE => cascade # class UserStatistics < ApplicationRecord belongs_to :user, inverse_of: :statistics, optional: true def self.trim_old_stats_models UserStatistics.where('day < ?', 91.days.ago.to_i_timestamp).delete_all end end