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
لدي نفس المشكلة، لكن مع المستخدمين الذين أحتاج إلى إزالتهم قبل إجراء الاستيراد النهائي. كنت أعمل على إعداد بيئة أساسية تحتوي على جميع الإعدادات والمظاهر وما إلى ذلك قبل الاستيراد، والآن (بعد الكثير من العمل) اكتشفت أنني قمت بذلك على استيراد جزئي قد استورد بالفعل 4000 مستخدم.
أرغب في حذف هؤلاء المستخدمين حتى لا يتلقى أي شخص رسائل بريد إلكتروني عن الملخصات أو أي شيء آخر (عندما أنسى تغيير تلك الإعدادات).
كيف يمكنني تعديل هذا الاستعلام بحيث يبقى فقط مستخدم المشرف؟
هناك حوالي 4000 مستخدم في قائمة المستخدمين النشطين
وحوالي 30 في قائمة المستخدمين المعلقين.