2021-06-08 01:34:01 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DirectoryColumn < ActiveRecord::Base
|
2021-06-17 22:06:18 +08:00
|
|
|
self.inheritance_column = nil
|
|
|
|
|
|
|
|
def self.automatic_column_names
|
|
|
|
@automatic_column_names ||= [:likes_received,
|
|
|
|
:likes_given,
|
|
|
|
:topics_entered,
|
|
|
|
:topic_count,
|
|
|
|
:post_count,
|
|
|
|
:posts_read,
|
|
|
|
:days_visited]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.active_column_names
|
|
|
|
DirectoryColumn.where(type: [:automatic, :plugin]).where(enabled: true).pluck(:name).map(&:to_sym)
|
|
|
|
end
|
|
|
|
|
|
|
|
@@plugin_directory_columns = []
|
|
|
|
|
|
|
|
enum type: { automatic: 0, user_field: 1, plugin: 2 }
|
|
|
|
|
2021-06-08 01:34:01 +08:00
|
|
|
belongs_to :user_field
|
2021-06-17 22:06:18 +08:00
|
|
|
|
|
|
|
def self.add_plugin_directory_column(name)
|
|
|
|
@@plugin_directory_columns << name
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.plugin_directory_columns
|
|
|
|
@@plugin_directory_columns
|
|
|
|
end
|
2021-06-08 01:34:01 +08:00
|
|
|
end
|