mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'story/116761157-contact-dyn-states' into staging
This commit is contained in:
commit
a3570b858e
1 changed files with 4 additions and 3 deletions
|
@ -189,9 +189,9 @@ class Contact < ActiveRecord::Base
|
||||||
scope = all
|
scope = all
|
||||||
|
|
||||||
# all contacts has state ok, so no need to filter by it
|
# all contacts has state ok, so no need to filter by it
|
||||||
states.delete(OK)
|
scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") if states.delete(OK)
|
||||||
scope = scope.find_linked if states.delete(LINKED)
|
scope = scope.find_linked if states.delete(LINKED)
|
||||||
scope = scope.where( "contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
|
scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
|
||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -266,8 +266,9 @@ class Contact < ActiveRecord::Base
|
||||||
# to too many places
|
# to too many places
|
||||||
def statuses
|
def statuses
|
||||||
calculated = Array(read_attribute(:statuses))
|
calculated = Array(read_attribute(:statuses))
|
||||||
|
calculated.delete(Contact::OK)
|
||||||
calculated.delete(Contact::LINKED)
|
calculated.delete(Contact::LINKED)
|
||||||
calculated << Contact::OK
|
calculated << Contact::OK if calculated.empty? && valid?
|
||||||
calculated << Contact::LINKED if domains_present?
|
calculated << Contact::LINKED if domains_present?
|
||||||
|
|
||||||
calculated.uniq
|
calculated.uniq
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue