I have imported my old data from phpBB3 which went smooth. But I made a mistake by not first cleaning up the old inactive users and still importing them. I now have around 4000 users with no posts I wish to remove.
These instructions produce the following error: [1] pry(main)> User.where(post_count: 0).destroy_all ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column users.post_count does not exist LINE 1: SELECT "users".* FROM "users" WHERE "users"."post_count" = 0 ^ : SELECT "users".* FROM "users" WHERE "users"."post_count" = 0 from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-mini-profiler-0.10.1/lib/patches/db/pg.rb:90:in `exec'
This is not really documented I think but if it is please point me in the right direction?
One of my sites uses SSO and we’re looking to remove users that have never posted and haven’t been seen in a year (to avoid killing users who are just quiet). Is this query valid in the rails console?
User.joins(:user_stat).where("user_stats.post_count = 0 AND previous_visit_at <= '2016-05-20'::timestamp").destroy_all
저도 같은 문제를 겪고 있습니다. 다만 최종 가져오기(import) 전에 삭제해야 하는 사용자들과 관련이 있습니다. 가져오기를 수행하기 전에 모든 설정/테마/기타 항목을 포함한 기본 세팅을 만드는 작업을 해왔는데, 막상 작업을 마친 후에 보니 이미 4,000명의 사용자가 가져와진 부분 가져오기 상태였다는 것을 알게 되었습니다.
그 사용자를 삭제해서 제가 해당 설정을 변경하는 것을 잊어버렸을 때, 다이제스트나 기타 이메일이 실수로 발송되지 않도록 하고 싶습니다.
쿼리를 어떻게 수정해야 관리자 사용자만 남게 될까요?
활성 사용자 목록에는 약 4,000명,
정지된 사용자 목록에는 약 30명이 있습니다.