Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

recreate compatibility with rest of the codebase

ulferts15b3f13e20bf
diff --git a/app/services/params_to_query_service.rb b/app/services/params_to_query_service.rb
index 91ad6a538b8..596414ff5bb 100644
--- a/app/services/params_to_query_service.rb
+++ b/app/services/params_to_query_service.rb
@@ -49,12 +49,8 @@ class ParamsToQueryService
private
def find_query(query_id)
- model_name = model.name
-
- if "::Queries::#{model_name.pluralize}".constantize.const_defined?(:Factory)
- factory = "::Queries::#{model_name.pluralize}::Factory".constantize
-
- factory.find(query_id)
+ if query_factory_class
+ query_factory_class.find(query_id)
elsif query_class.respond_to?(:find) && query_id
query_class.find(query_id)
else
@@ -153,4 +149,11 @@ class ParamsToQueryService
"::Queries::#{model_name.pluralize}::#{model_name.demodulize}Query".constantize
end
end
+
+ def query_factory_class
+ return nil unless Queries.const_defined?(model.name.pluralize) &&
+ "::Queries::#{model.name.pluralize}".constantize.const_defined?(:Factory)
+
+ "::Queries::#{model.name.pluralize}::Factory".constantize
+ end
end
diff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rb
index 032dd0e71ea..cdf796a7704 100644
--- a/lib/api/v3/utilities/endpoints/index.rb
+++ b/lib/api/v3/utilities/endpoints/index.rb
@@ -117,7 +117,7 @@ module API
end
def calculate_groups(query)
- return unless query.group_by
+ return unless query.respond_to?(:group_by) && query.group_by
query.group_values.map do |group, count|
::API::Decorators::AggregationGroup.new(group, count, query:, current_user: User.current)