mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Story#116761157 - "ok" state of Contact is not always set and is dynamic
This commit is contained in:
parent
d1e5312b98
commit
e9cf8f7900
3 changed files with 10 additions and 5 deletions
|
@ -187,9 +187,9 @@ class Contact < ActiveRecord::Base
|
|||
scope = all
|
||||
|
||||
# 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.where( "contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
|
||||
scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
|
||||
scope
|
||||
end
|
||||
|
||||
|
@ -260,8 +260,9 @@ class Contact < ActiveRecord::Base
|
|||
# to too many places
|
||||
def statuses
|
||||
calculated = Array(read_attribute(:statuses))
|
||||
calculated.delete(Contact::OK)
|
||||
calculated.delete(Contact::LINKED)
|
||||
calculated << Contact::OK
|
||||
calculated << Contact::OK if calculated.empty? && valid?
|
||||
calculated << Contact::LINKED if domains_present?
|
||||
|
||||
calculated.uniq
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue