Updated

app/models / trending_domain.rb

A
40 lines of codes
5 methods
5.0 complexity/method
2 churn
24.84 complexity
0 duplications
class TrendingDomain < ActiveRecord::Base
  1. TrendingDomain has no descriptive comment
belongs_to :petition validates :domain, presence: true, length: { maximum: 100 } validates :count, presence: true, numericality: { only_integer: true, greater_than: 0 } validates :starts_at, presence: true attr_readonly(:domain, :count, :starts_at) class << self def default_scope order(created_at: :desc, count: :desc) end def log!(time, domain, count)
  1. TrendingDomain has missing safe method 'log!'
create!(domain: domain, count: count, starts_at: time) end def search(query, options = {}) query = query.to_s page = [options[:page].to_i, 1].max if query.present? scope = where(domain: query) else scope = all end scope.paginate(page: page, per_page: 50) end end def ends_at starts_at.advance(hours: 1) end def window starts_at.getutc.iso8601(0) end end