Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list() methods and deprecate all() methods #329

Merged
merged 29 commits into from
Oct 17, 2023

Conversation

Art4
Copy link
Collaborator

@Art4 Art4 commented Sep 28, 2023

There has always been confusion using the retrieveAll() and all() methods, because the methods have a default limit of 25 and therefore not returns all entries. (#35, #46, #172, #277). The default limit of 25 and max limit of 100 is set by Redmine, see https://www.redmine.org/projects/redmine/wiki/Rest_api#Collection-resources-and-pagination Nevertheless we are able to push the max limit above 100 by making multiple requests internally and merge the results.

This PR deprecates every all() method in all API classes and it adds new methods like list(), listByIssueId() and listByProject() as replacements. This hopefully remove the wrong assumption that all() really means all.

In this PR we also introduce a new unit testing strategy where every method will get a separate test class where every aspect of the method can be tested.

I propose this PR for Release v2.4.0.

Next we have the listing() methods that returns an array as name => id or id => name. These methods are inconsistent implemented and are based on a cache filled up by a previous call of all()/list() what can be confusing. I will take care of this in a separate issue, see #338.

Closes #277.

Todo

  • Create CustomField::list()
  • Create Group::list()
  • Create Issue::list()
  • Create IssueCategory::listByProject()
  • Create IssuePriority::list()
  • Create IssueRelation::listByIssueId()
  • Create IssueStatus::list()
  • Create Membership::listByProject()
  • Create News::list()
  • Create News::listByProject()
  • Create Project::list()
  • Create Query::list()
  • Create Role::list()
  • Create Search::listByQuery()
  • Create TimeEntry::list()
  • Create TimeEntryActivity::list()
  • Create Tracker::list()
  • Create User::list()
  • Create Version::listByProject()
  • Create Wiki::listByProject()
  • Update examples in docs/usage.md
  • Update examples in README.md

Overview

mid-level API all() arguments all() returns all() replacement
Attachment - - -
CustomField $params full data as array list($params)
Group $params full data as array list($params)
Isuse $params full data as array list($params)
IssueCategory $project_identifier, $params full data as array listByProject($project_identifier, $params)
IssuePriority $params full data as array list($params)
IssueRelation $issueId, $params full data as array listByIssueId($issueId, $params)
IssueStatus $params full data as array list($params)
Membership $project_identifier, $params full data as array listByProject($project_identifier, $params)
News $project_identifier|null, $params full data as array list($params) and listByProject($project_identifier, $params)
Project $params full data as array list($params)
Query $params full data as array list($params)
Role $params full data as array list($params)
Search - - listByQuery($params)
TimeEntry $params full data as array list($params)
TimeEntryActivity $params full data as array list($params)
Tracker $params full data as array list($params)
User $params full data as array list($params)
Version $project_identifier, $params full data as array listByProject($project_identifier, $params)
Wiki $project_identifier, $params full data as array listByProject($project_identifier, $params)

@Art4 Art4 self-assigned this Sep 28, 2023
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (b76bcf1) 95.32% compared to head (151d20e) 95.98%.

Additional details and impacted files
@@             Coverage Diff              @@
##               v2.x     #329      +/-   ##
============================================
+ Coverage     95.32%   95.98%   +0.65%     
- Complexity      365      395      +30     
============================================
  Files            27       27              
  Lines          1134     1220      +86     
============================================
+ Hits           1081     1171      +90     
+ Misses           53       49       -4     
Files Coverage Δ
src/Redmine/Api/CustomField.php 100.00% <100.00%> (ø)
src/Redmine/Api/Group.php 100.00% <100.00%> (ø)
src/Redmine/Api/Issue.php 100.00% <100.00%> (ø)
src/Redmine/Api/IssueCategory.php 100.00% <100.00%> (ø)
src/Redmine/Api/IssuePriority.php 100.00% <100.00%> (ø)
src/Redmine/Api/IssueRelation.php 100.00% <100.00%> (ø)
src/Redmine/Api/IssueStatus.php 100.00% <100.00%> (ø)
src/Redmine/Api/Membership.php 100.00% <100.00%> (ø)
src/Redmine/Api/News.php 100.00% <100.00%> (ø)
src/Redmine/Api/Project.php 100.00% <100.00%> (ø)
... and 9 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Art4 Art4 modified the milestones: v2.3.0, v2.4.0 Oct 9, 2023
@Art4 Art4 requested a review from kbsali October 11, 2023 07:09
@Art4 Art4 marked this pull request as ready for review October 11, 2023 07:09
@Art4 Art4 merged commit 5277a93 into kbsali:v2.x Oct 17, 2023
7 checks passed
@Art4 Art4 deleted the 277-deprecate-all-and-listings-methods branch October 17, 2023 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is a default limit set even I use the retrieveAll method.
1 participant