Files
docuseal/app/controllers/api/submission_events_controller.rb
T

41 lines
1.4 KiB
Ruby
Raw Normal View History

2024-08-13 00:27:40 +03:00
# frozen_string_literal: true
module Api
class SubmissionEventsController < ApiBaseController
load_and_authorize_resource :submission, parent: false
def index
2026-07-01 21:50:12 +03:00
submissions = @submissions.active.where.not(completed_at: nil)
2024-08-13 00:27:40 +03:00
params[:after] = Time.zone.at(params[:after].to_i) if params[:after].present?
params[:before] = Time.zone.at(params[:before].to_i) if params[:before].present?
submissions = paginate(submissions.preload(
:created_by_user, :submission_events,
template: :folder,
submitters: { documents_attachments: :blob, attachments_attachments: :blob },
2025-08-31 16:40:18 +03:00
audit_trail_attachment: :blob,
combined_document_attachment: :blob
2024-08-13 00:27:40 +03:00
),
field: :completed_at)
2025-08-31 16:40:18 +03:00
expires_at = Accounts.link_expires_at(current_account)
2024-08-13 00:27:40 +03:00
render json: {
data: submissions.map do |s|
{
event_type: 'submission.completed',
timestamp: s.completed_at,
2025-08-31 16:40:18 +03:00
data: Submissions::SerializeForApi.call(s, s.submitters, expires_at:)
2024-08-13 00:27:40 +03:00
}
end,
pagination: {
count: submissions.size,
next: submissions.last&.completed_at&.to_i,
prev: submissions.first&.completed_at&.to_i
}
}
end
end
end