diff options
Diffstat (limited to 'app/models/concerns/usage_statistics.rb')
-rw-r--r-- | app/models/concerns/usage_statistics.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/concerns/usage_statistics.rb b/app/models/concerns/usage_statistics.rb new file mode 100644 index 00000000000..d6cafcb22b1 --- /dev/null +++ b/app/models/concerns/usage_statistics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module UsageStatistics + extend ActiveSupport::Concern + + class_methods do + def distinct_count_by(column = nil, fallback = -1) + distinct.count(column) + rescue ActiveRecord::StatementInvalid + fallback + end + end +end |