BigW Consortium Gitlab

Commit 061a0703 by Yorick Peterse Committed by DJ Mountney

Merge branch 'zj-slow-service-fetch' into 'master'

Improve performance of triggered chat commands See merge request !8876
parent 2ef2d97a
---
title: Improve performance of slash commands
merge_request: 8876
author:
......@@ -619,6 +619,14 @@ module API
end
trigger_services.each do |service_slug, settings|
helpers do
def chat_command_service(project, service_slug, params)
project.services.active.where(template: false).find do |service|
service.try(:token) == params[:token] && service.to_param == service_slug.underscore
end
end
end
params do
requires :id, type: String, desc: 'The ID of a project'
end
......@@ -637,9 +645,8 @@ module API
# This is not accurate, but done to prevent leakage of the project names
not_found!('Service') unless project
service = project.find_or_initialize_service(service_slug.underscore)
result = service.try(:active?) && service.try(:trigger, params)
service = chat_command_service(project, service_slug, params)
result = service.try(:trigger, params)
if result
status result[:status] || 200
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment