Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging deploy #361

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/serializers/directory_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DirectorySerializer < ActiveModel::Serializer
def attributes(*args)
object.attributes.symbolize_keys.except(:id, :created_at, :updated_at)
end
end
6 changes: 1 addition & 5 deletions app/serializers/indexed_services_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ class IndexedServicesSerializer < ActiveModel::Serializer
:created_at,
:status

has_many :directories do
object.directories.map do |directory|
{ name: directory.name, label: directory.label }
end
end
has_many :directories

has_many :locations do
object.locations.where(visible: true)
Expand Down
28 changes: 12 additions & 16 deletions lib/tasks/update_public_index.rake
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@ task :update_public_index => :environment do

# active services are all indexed
when 'active'
upsert_active = collection.find_one_and_update({ id: service.id },
collection.find_one_and_update({ id: service.id },
IndexedServicesSerializer.new(service).as_json,
{ upsert: true })
active_count += 1
active_ids << upsert_active[:id]
puts "ACTIVE: #{service.name} indexed"
active_ids << service.id

# temporarily closed services are all indexed
when 'temporarily closed'
upsert_temporarily_closed = collection.find_one_and_update({ id: service.id },
collection.find_one_and_update({ id: service.id },
IndexedServicesSerializer.new(service).as_json,
{ upsert: true })
temporarily_closed_count += 1
temporarily_closed_ids << upsert_temporarily_closed[:id]
puts "TEMPORARILY CLOSED: #{service.name} indexed"
temporarily_closed_ids << service.id

# scheduled services are all indexed - the API determines if they're returned or not
when 'scheduled'
upsert_scheduled = collection.find_one_and_update({ id: service.id },
collection.find_one_and_update({ id: service.id },
IndexedServicesSerializer.new(service).as_json,
{ upsert: true })
scheduled_count += 1
scheduled_ids << upsert_scheduled[:id]
puts "SCHEDULED: #{service.name} indexed"
scheduled_ids << service.id


# archived services are removed from the index
when 'archived'
deleted_archived = collection.find_one_and_delete({ id: service.id })
archived_count += 1
if deleted_archived
archived_ids << service.id
puts "🗑 ARCHIVED: #{service.name} deleted"
archived_ids << deleted_archived[:id]
else
puts "⚠️ ARCHIVED: #{service.name} not found in index, skipping"
end
Expand All @@ -63,8 +63,8 @@ task :update_public_index => :environment do
deleted_expired = collection.find_one_and_delete({ id: service.id })
expired_count += 1
if deleted_expired
expired_ids << service.id
puts "🗑 EXPIRED: #{service.name} deleted"
expired_ids << deleted_expired[:id]
else
puts "⚠️ EXPIRED: #{service.name} not found in index, skipping"
end
Expand All @@ -74,8 +74,8 @@ task :update_public_index => :environment do
deleted_invisible = collection.find_one_and_delete({ id: service.id })
deleted_count += 1
if deleted_invisible
invisible_ids << service.id
puts "🗑 INVISIBLE: #{service.name} deleted"
invisible_ids << deleted_invisible[:id]
else
puts "⚠️ INVISIBLE: #{service.name} not found in index, skipping"
end
Expand All @@ -85,8 +85,8 @@ task :update_public_index => :environment do
deleted_marked_for_deletion = collection.find_one_and_delete({ id: service.id })
marked_for_deletion_count += 1
if deleted_marked_for_deletion
marked_for_deletion_ids << service.id
puts "🗑 MARKED FOR DELETION: #{service.name} deleted"
marked_for_deletion_ids << deleted_marked_for_deletion[:id]
else
puts "⚠️ MARKED FOR DELETION: #{service.name} not found in index, skipping"
end
Expand All @@ -105,12 +105,12 @@ task :update_public_index => :environment do
end

snapshot = Service.from_hash(approved_alternative.object)
upsert_pending = collection.find_one_and_update({ id: service.id },
collection.find_one_and_update({ id: service.id },
IndexedServicesSerializer.new(snapshot).as_json,
{ upsert: true })
puts "🤔 Alternative approved snapshot of #{service.name} indexed"
pending_count += 1
pending_ids << upsert_pending[:id]
pending_ids << service.id
end
end

Expand Down Expand Up @@ -156,7 +156,3 @@ task :update_public_index => :environment do
puts "Pending Services"
puts " 👉 #{pending_count} pending services, #{pending_ids.length} created."
end


def create_update_service(service)
end