From 86f62c4e1a422d675a863d218f48816e50ed13c3 Mon Sep 17 00:00:00 2001 From: Toon Willems Date: Mon, 23 Dec 2024 08:51:48 +0100 Subject: [PATCH] tmp --- app/models/subscription_event_trigger.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/subscription_event_trigger.rb b/app/models/subscription_event_trigger.rb index 33b719396e4..d07c2d09b75 100644 --- a/app/models/subscription_event_trigger.rb +++ b/app/models/subscription_event_trigger.rb @@ -3,9 +3,15 @@ class SubscriptionEventTrigger < ApplicationRecord validates :organization_id, :external_subscription_id, :created_at, presence: true + scope :ordered, -> { order(created_at: :desc) } + def self.trigger(organization_id:, external_subscription_id:) connection.select_all sanitize_sql_array(["call trigger_subscription_update(?,?, null)", organization_id, external_subscription_id]) end + + def self.take + candidate = SubscriptionEventTrigger.ordered.limit(1) + end end # == Schema Information