GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sql-cms/app/models/data_quality_report.rb at master · evilbuck/sql-cms Expand file tree/ Copy pathdata_quality_report.rbMore file actions 78 lines (59 loc) · 2.04 KB / Copy pathdata_quality_report.rbFile metadata and controls78 lines (59 loc) · 2.04 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 # frozen_string_literal: true # == Schema Information # # Table name: data_quality_reports # # id :integer not null, primary key # name :string not null # sql :text not null # created_at :datetime not null # updated_at :datetime not null # immutable :boolean default(FALSE) # # Indexes # # index_data_quality_reports_on_lowercase_name (lower((name)::text)) UNIQUE # class DataQualityReport < ApplicationRecord auto_normalize except: :sql # Validations validates :sql, presence: true validates :name, presence: true, uniqueness: { case_sensitive: false } # Callbacks include Concerns::ImmutableCallbacks immutable :update, :destroy # Associations has_many :workflow_data_quality_reports, inverse_of: :data_quality_report, dependent: :delete_all has_many :workflows, through: :workflow_data_quality_reports # Instance Methods def usage_count workflow_data_quality_reports.count end def used? usage_count > 0 end # Class Methods class << self def table_count @table_count ||= where(name: 'Table :table_name Count').first_or_create!( immutable: true, sql: 'SELECT COUNT(1) FROM :table_name' ) end def column_value_distribution @column_value_distribution ||= where(name: 'Column :table_name.:column_name Value Distribution').first_or_create!( immutable: true, sql: "SELECT :column_name, COUNT(1) AS count FROM :table_name GROUP BY :column_name ORDER BY count DESC" ) end def column_non_unique_value_distribution @column_non_unique_value_distribution ||= where(name: 'Column :table_name.:column_name Non-Unique Value Distribution').first_or_create!( immutable: true, sql: "SELECT :column_name, COUNT(1) AS count FROM :table_name GROUP BY :column_name HAVING COUNT(:column_name) > 1 ORDER BY count DESC" ) end def flush_cache @table_count = @column_value_distribution = @column_non_unique_value_distribution = nil end end end |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |