From 554a6169638a4744c4945fc2fc1a7b48f5ce232f Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 11 Aug 2015 15:47:39 -0700 Subject: [PATCH] fixes #2481: Include approvers on janitor trial report --- app/logical/reports/janitor_trials.rb | 2 +- lib/danbooru/has_bit_flags.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/logical/reports/janitor_trials.rb b/app/logical/reports/janitor_trials.rb index 26c69e1e7..445a32097 100644 --- a/app/logical/reports/janitor_trials.rb +++ b/app/logical/reports/janitor_trials.rb @@ -39,7 +39,7 @@ module Reports end def janitors - User.where("level >= ?", User::Levels::JANITOR).to_a.map {|x| Janitor.new(x)} + User.where("bit_prefs & ? > 0", User.flag_value_for("can_approve_posts")).to_a.map {|x| Janitor.new(x)} end end end diff --git a/lib/danbooru/has_bit_flags.rb b/lib/danbooru/has_bit_flags.rb index 7e66d5eb5..66ec54008 100644 --- a/lib/danbooru/has_bit_flags.rb +++ b/lib/danbooru/has_bit_flags.rb @@ -11,6 +11,12 @@ module Danbooru attributes.each.with_index do |attribute, i| bit_flag = 1 << i + define_singleton_method("flag_value_for") do |key| + index = attributes.index(key) + raise IndexError if index.nil? + 1 << index + end + define_method(attribute) do send(field) & bit_flag > 0 end