A platform for community discussion. Free, open, simple.
FEATURE: Create new helper method 'Discourse.stats' (#7388)
Vinoth Kannana8f410a9c56c
diff --git a/lib/discourse.rb b/lib/discourse.rbindex a6476dc5af6..f1c9f069d55 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -468,6 +468,10 @@ module Discourseendend+ def self.stats+ @stats ||= PluginStore.new("stats")+ end+def self.current_user_provider@current_user_provider || Auth::DefaultCurrentUserProviderenddiff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rbindex f6b053a27b2..8ec4ff5f451 100644--- a/lib/s3_inventory.rb+++ b/lib/s3_inventory.rb@@ -65,7 +65,7 @@ class S3Inventorylog "#{missing_count} of #{uploads.count} #{model.name.underscore.pluralize} are missing"end- $redis.set("missing_s3_#{model.table_name}", missing_count)+ Discourse.stats.set("missing_s3_#{model.table_name}", missing_count)ensureconnection.exec("DROP TABLE #{table_name}") unless connection.nil?enddiff --git a/spec/components/s3_inventory_spec.rb b/spec/components/s3_inventory_spec.rbindex bed034585a1..b6734641619 100644--- a/spec/components/s3_inventory_spec.rb+++ b/spec/components/s3_inventory_spec.rb@@ -75,7 +75,7 @@ describe "S3Inventory" doendexpect(output).to eq("#{upload.url}\n1 of 4 uploads are missing\n")- expect($redis.get("missing_s3_uploads")).to eq("1")+ expect(Discourse.stats.get("missing_s3_uploads")).to eq(1)endit "should backfill etags to uploads table correctly" do