Sha256: 0b0f1477806bc9c9beb123310174006fd56d23470e377af236d152cacc491ee6
Contents?: true
Size: 924 Bytes
Versions: 94
Compression:
Stored size: 924 Bytes
Contents
module Feedback class Resource < ApplicationRecord has_many :feedbacks, dependent: :destroy before_validation :set_product validates :uri, presence: true, allow_blank: false def display_name uri end def score if feedbacks.any? score_value.round(1) else 'n/a' end end def score_value ((feedbacks.positive.count / feedbacks.count.to_f) * 100.to_f) end def relative_link URI(uri).path end def self.worst_performing all.select { |resource| resource.feedbacks.count > 5 }.sort_by(&:score_value) end def self.best_performing worst_performing.reverse end private def set_product products = DocumentationConstraint.product_with_parent_list self.product = products.detect do |product| break product if URI(uri).path.start_with? "/#{product}" end end end end
Version data entries
94 entries across 94 versions & 1 rubygems