Adjust exporter and user count to match new ban system
This commit is contained in:
parent
59c4507ec3
commit
a533f68c65
|
@ -17,13 +17,19 @@ class StaticController < ApplicationController
|
|||
end
|
||||
|
||||
def about
|
||||
@users = User
|
||||
user_count = User
|
||||
.where.not(confirmed_at: nil)
|
||||
.where(permanently_banned: false)
|
||||
.where(banned_until: nil)
|
||||
.where('answered_count > 0')
|
||||
.where("answered_count > 0")
|
||||
.count
|
||||
|
||||
current_ban_count = UserBan
|
||||
.current
|
||||
.joins(:user)
|
||||
.where.not("users.confirmed_at": nil)
|
||||
.where("users.answered_count > 0")
|
||||
.count
|
||||
|
||||
@users = user_count - current_ban_count
|
||||
@questions = Question.count
|
||||
@answers = Answer.count
|
||||
@comments = Comment.count
|
||||
|
|
|
@ -34,10 +34,10 @@ class Exporter
|
|||
private
|
||||
|
||||
def collect_user_info
|
||||
%i(answered_count asked_count ban_reason banned_until comment_smiled_count commented_count
|
||||
%i(answered_count asked_count comment_smiled_count commented_count
|
||||
confirmation_sent_at confirmed_at created_at profile_header profile_header_h profile_header_w profile_header_x profile_header_y
|
||||
profile_picture_w profile_picture_h profile_picture_x profile_picture_y current_sign_in_at current_sign_in_ip
|
||||
id last_sign_in_at last_sign_in_ip locale permanently_banned
|
||||
id last_sign_in_at last_sign_in_ip locale
|
||||
privacy_allow_anonymous_questions privacy_allow_public_timeline privacy_allow_stranger_answers
|
||||
privacy_show_in_search profile_header_file_name profile_picture_file_name
|
||||
screen_name show_foreign_themes sign_in_count smiled_count updated_at).each do |f|
|
||||
|
|
|
@ -8,9 +8,9 @@ describe StaticController, type: :controller do
|
|||
|
||||
before(:each) {
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 })
|
||||
FactoryBot.create(:user, { permanently_banned: true })
|
||||
FactoryBot.create(:user, { banned_until: Time.current + 10.days })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 }).ban
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current }).ban
|
||||
}
|
||||
|
||||
it "shows the correct user count" do
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require 'exporter'
|
||||
require "rails_helper"
|
||||
require "exporter"
|
||||
|
||||
RSpec.describe Exporter do
|
||||
let(:params) { {
|
||||
answered_count: 144,
|
||||
asked_count: 72,
|
||||
ban_reason: nil,
|
||||
banned_until: nil,
|
||||
comment_smiled_count: 15,
|
||||
commented_count: 12,
|
||||
confirmation_sent_at: 2.weeks.ago.utc,
|
||||
|
@ -19,7 +17,6 @@ RSpec.describe Exporter do
|
|||
last_sign_in_at: 1.hour.ago,
|
||||
last_sign_in_ip: '192.0.2.14',
|
||||
locale: 'en',
|
||||
permanently_banned: false,
|
||||
privacy_allow_anonymous_questions: true,
|
||||
privacy_allow_public_timeline: false,
|
||||
privacy_allow_stranger_answers: false,
|
||||
|
|
Loading…
Reference in New Issue