refactor: refactor webhook deliveries

This commit is contained in:
Adam Cooke
2024-02-23 22:51:33 +00:00
committed by Adam Cooke
parent 6eb16c3fab
commit e0403ba641
6 changed files with 209 additions and 55 deletions
+1 -1
View File
@@ -325,7 +325,7 @@ module Postal
result = connection.query(query, cast_booleans: true)
time = Time.now.to_f - start_time
logger.debug " \e[4;34mMessageDB Query (#{time.round(2)}s) \e[0m \e[33m#{query}\e[0m"
if time.positive? && query =~ /\A(SELECT|UPDATE|DELETE) /
if time > 0.05 && query =~ /\A(SELECT|UPDATE|DELETE) /
id = Nifty::Utils::RandomString.generate(length: 6).upcase
explain_result = ResultForExplainPrinter.new(connection.query("EXPLAIN #{query}"))
logger.info " [#{id}] EXPLAIN #{query}"
+1 -1
View File
@@ -12,7 +12,7 @@ module Postal
@database.insert(:webhook_requests, attributes)
end
def list(page)
def list(page = 1)
result = @database.select_with_pagination(:webhook_requests, page, order: :timestamp, direction: "desc")
result[:records] = result[:records].map { |i| Request.new(i) }
result