about summary refs log tree commit diff
path: root/app/models/account_summary.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-04-20 18:06:40 +0200
committerGitHub <noreply@github.com>2021-04-20 18:06:40 +0200
commit97da7b73071e9f515c4bb0bca72c88d1a13b14aa (patch)
tree89c81064b9e3725962a847e98099a5b84b728733 /app/models/account_summary.rb
parentdf326b8b5c0659edb2aca77690a892f228b0e099 (diff)
parent4b115d070c9a8b6082ed207bd0a14e809eded322 (diff)
Merge pull request #1521 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/account_summary.rb')
-rw-r--r--app/models/account_summary.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/account_summary.rb b/app/models/account_summary.rb
new file mode 100644
index 000000000..6a7e17c6c
--- /dev/null
+++ b/app/models/account_summary.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+# == Schema Information
+#
+# Table name: account_summaries
+#
+#  account_id :bigint(8)        primary key
+#  language   :string
+#  sensitive  :boolean
+#
+
+class AccountSummary < ApplicationRecord
+  self.primary_key = :account_id
+
+  scope :safe, -> { where(sensitive: false) }
+  scope :localized, ->(locale) { where(language: locale) }
+  scope :filtered, -> { joins(arel_table.join(FollowRecommendationSuppression.arel_table, Arel::Nodes::OuterJoin).on(arel_table[:account_id].eq(FollowRecommendationSuppression.arel_table[:account_id])).join_sources).where(FollowRecommendationSuppression.arel_table[:id].eq(nil)) }
+
+  def self.refresh
+    Scenic.database.refresh_materialized_view(table_name, concurrently: true, cascade: false)
+  end
+
+  def readonly?
+    true
+  end
+end