Class: AccreditedOrganization
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AccreditedOrganization
- Defined in:
- app/models/accredited_organization.rb
Class Method Summary collapse
-
.find_within_max_distance(long, lat, max_distance = AccreditedRepresentation::Constants::DEFAULT_MAX_DISTANCE) ⇒ AccreditedOrganization::ActiveRecord_Relation
Find all [AccreditedOrganizations] that are located within a distance of a specific location.
-
.max_per_page ⇒ Object
This method needs to exist on the model so [Common::Collection] doesn’t blow up when trying to paginate.
Instance Method Summary collapse
-
#registration_numbers ⇒ Array<String>
return all registration_numbers associated with the organization.
Methods inherited from ApplicationRecord
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Class Method Details
.find_within_max_distance(long, lat, max_distance = AccreditedRepresentation::Constants::DEFAULT_MAX_DISTANCE) ⇒ AccreditedOrganization::ActiveRecord_Relation
Find all [AccreditedOrganizations] that are located within a distance of a specific location
34 35 36 37 38 39 40 |
# File 'app/models/accredited_organization.rb', line 34 def self.find_within_max_distance(long, lat, max_distance = AccreditedRepresentation::Constants::DEFAULT_MAX_DISTANCE) query = 'ST_DWithin(ST_SetSRID(ST_MakePoint(:long, :lat), 4326)::geography,' \ 'accredited_organizations.location, :max_distance)' params = { long:, lat:, max_distance: } where(query, params) end |
.max_per_page ⇒ Object
This method needs to exist on the model so [Common::Collection] doesn’t blow up when trying to paginate
50 51 52 |
# File 'app/models/accredited_organization.rb', line 50 def self.max_per_page AccreditedRepresentation::Constants::MAX_PER_PAGE end |
Instance Method Details
#registration_numbers ⇒ Array<String>
return all registration_numbers associated with the organization
45 46 47 |
# File 'app/models/accredited_organization.rb', line 45 def registration_numbers accredited_individuals.pluck(:registration_number) end |