app/models/unidom/action/searching.rb in unidom-action-1.12 vs app/models/unidom/action/searching.rb in unidom-action-1.13

- old
+ new

@@ -14,11 +14,11 @@ validates :total_pages, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 } validates :current_page, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 } belongs_to :searcher_visitor, polymorphic: true belongs_to :searcher_party, polymorphic: true - belongs_to :searcher_reason, class_name: 'Unidom::Action::Reason' + belongs_to :reason, class_name: 'Unidom::Action::Reason' scope :searched_by, ->(searcher_party) { where searcher_party: searcher_party } scope :searched_via, ->(searcher_visitor) { where searcher_visitor: searcher_visitor } scope :caused_by, ->(reason) { where reason_id: to_id(reason) } @@ -29,7 +29,13 @@ scope :found_count_is, ->(found_count) { where found_count: found_count } scope :shown_count_is, ->(shown_count) { where shown_count: shown_count } scope :per_page_is, ->(per_page) { where per_page: per_page } scope :current_page_is, ->(current_page) { where current_page: current_page } scope :total_pages_is, ->(total_pages) { where total_pages: total_pages } + + def self.search!(it, on: '', version: '1', per: {}, due_to: nil, by: nil, via: nil, at: Time.now, displaying: 0, of_total: 0, on_current_page: 0, of_total_page: 0, per_page: 0) + create! resource_name: it, platform_name: on, platform_version: version, criteria: per, + reason: due_to, searcher_party: by, searcher_visitor: via, opened_at: at, + shown_count: displaying, found_count: of_total, current_page: on_current_page, total_pages: of_total_page, per_page: per_page + end end