optimize queries

This commit is contained in:
Pete Matsyburka
2026-06-24 15:23:25 +03:00
parent 432435aa23
commit c18ddb99a8
3 changed files with 7 additions and 11 deletions
+3 -3
View File
@@ -30,9 +30,9 @@ module Mcp
def call(arguments, _current_user, current_ability)
template = Template.accessible_by(current_ability).find_by(id: arguments['template_id'])
return { content: [{ type: 'text', text: 'Template not found' }], isError: true } unless template
current_ability.authorize!(:read, template)
if !template || !current_ability.can?(:read, template)
return { content: [{ type: 'text', text: 'Template not found' }], isError: true }
end
submitters_index = template.submitters.index_by { |s| s['uuid'] }
+3 -1
View File
@@ -73,7 +73,9 @@ module Mcp
def call(arguments, current_user, current_ability)
template = Template.accessible_by(current_ability).find_by(id: arguments['template_id'])
return { content: [{ type: 'text', text: 'Template not found' }], isError: true } unless template
if !template || !current_ability.can?(:read, template)
return { content: [{ type: 'text', text: 'Template not found' }], isError: true }
end
if template.archived_at?
return { content: [{ type: 'text', text: 'Template has been archived' }], isError: true }