Skip to content

Instantly share code, notes, and snippets.

@DevGW
Last active March 3, 2023 15:14
Show Gist options
  • Save DevGW/f24a15a2a6a5859361bd540d16f765d7 to your computer and use it in GitHub Desktop.
Save DevGW/f24a15a2a6a5859361bd540d16f765d7 to your computer and use it in GitHub Desktop.
FeedMonster OSN (create/update) to push #feedmonster #hha_ank

Pushing stuck OSNs

ARGUMENTS:

Resource: Record to push ( ex: EmployeeConsumerStatusRecord.find(1189203) )

EndPoint (Client:Module): ex: "cpma:bit"

Create vs Update:

Create will send a create event to the endpoint for the record so the endpoint will create it if it doesn't exist. Update will send an update event to the endpoint for the record and fail if it doesn't exist.

irb commands

FeedMonster.push_model_create_to_endpoint(Resource, EndPoint)
FeedMonster.push_model_update_to_endpoint(Resource, EndPoint)

Finding unsuccessful OSNs

MySQL

Count unsuccessful OSNs (last 60 days)

select push_to_endpoint_name, state, count(*) ct from outbound_service_notifications where state != 'success' and created_at > NOW() - INTERVAL 60 DAY group by push_to_endpoint_name, state order by state;

Show unsucccessful OSNs (last 60 days)

select * from outbound_service_notifications where state != 'success' and created_at > NOW() - INTERVAL 60 DAY group by push_to_endpoint_name, state order by state\G

ActiveRecord

Count unsuccessful OSNs (last 60 days)

OutboundServiceNotification.where.not(state: 'success').where("created_at > ?", 60.days.ago).group(:push_to_endpoint_name).group(:state).order(:push_to_endpoint_name, :state).count

Show unsucccessful OSNs (last 60 days)

Note: remove ".not(push_to_endpoint_name: 'dex')" to include dex endpoint

OutboundServiceNotification.where.not(state: 'success').where.not(push_to_endpoint_name: 'dex').where("created_at > ?", 60.days.ago).order(:push_to_endpoint_name, :state).limit(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment