Project

General

Profile

Actions

Defect #41791

closed

Projects endpoint returns list of all projects

Added by Łukasz Szczepański about 1 month ago. Updated 23 days ago.

Status:
Closed
Priority:
Normal
Category:
REST API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Redmine info:

Environment:
  Redmine version                6.0.1.stable
  Ruby version                   3.3.6-p108 (2024-11-05) [x86_64-linux]
  Rails version                  7.2.2
  Environment                    production
  Database adapter               PostgreSQL
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Alternate
SCM:
  Subversion                     1.14.2
  Mercurial                      6.3.2
  Bazaar                         3.3.2
  Git                            2.39.5
  Filesystem

As of version 6.0, the REST API /projects endpoint has started returning a list of all projects, instead of using the default limit of 25. Also, `limits` and `offset` do not seem to work on this endpoint.


Related issues

Related to Redmine - Feature #23954: Shows the date of the last activity on Projects administrationClosedMarius BĂLTEANU

Actions
Actions #1

Updated by Holger Just about 1 month ago

  • Related to Feature #23954: Shows the date of the last activity on Projects administration added
Actions #2

Updated by Holger Just about 1 month ago

  • Status changed from New to Confirmed

This was broken in r22811 for #23954.

Previously, the limit and offset was applied in the controller to the scope. With the change, this was delegated to ProjectController#project_scope, which just forwards this to ProjectQuery#results_scope. However, the ProjectQuery models does not set this.

A quick patch could be this, in addition to some tests:

index 6defbcc834..8386ca7d4b 100644
--- a/app/models/project_query.rb
+++ b/app/models/project_query.rb
@@ -158,6 +158,9 @@ def results_scope(options={})
       order(order_option).
       joins(joins_for_order_statement(order_option.join(',')))

+    scope = scope.limit(options[:limit]) if options.key?(:limit)
+    scope = scope.offset(options[:offset]) if options.key?(:offset)
+
     if has_custom_field_column?
       scope = scope.preload(:custom_values)
     end

Note that this bug also affects the list view of the projects list as well as the projects atom feed.

Actions #3

Updated by Marius BĂLTEANU about 1 month ago

  • Assignee set to Marius BĂLTEANU
  • Target version set to 6.0.2
Actions #4

Updated by Łukasz Szczepański about 1 month ago

I can confirm that this change resolves the issue

Actions #5

Updated by Marius BĂLTEANU 29 days ago

  • Status changed from Confirmed to Resolved
  • Resolution set to Fixed

I've committed the fix in r23300 which contains also a test for ProjectQuery.results_scope. I'll try to improve the test coverage for this issue.

Actions #6

Updated by Marius BĂLTEANU 23 days ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF