Skip to content

Commit 39de07d

Browse files
authored
Merge pull request #725 from gitlab4j/issue-656
Fix #656 : Re-support project issues statistics
2 parents a8ce9ec + 0da016b commit 39de07d

File tree

1 file changed

+44
-28
lines changed

1 file changed

+44
-28
lines changed

src/main/java/org/gitlab4j/api/IssuesApi.java

+44-28
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public Optional<Issue> getOptionalIssue(Object projectIdOrPath, Integer issueIid
387387
* Create an issue for the project.
388388
*
389389
* <pre><code>GitLab Endpoint: POST /projects/:id/issues</code></pre>
390-
*
390+
*
391391
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
392392
* @param title the title of an issue, required
393393
* @param description the description of an issue, optional
@@ -412,9 +412,9 @@ public Issue createIssue(Object projectIdOrPath, String title, String descriptio
412412
* @param labels comma-separated label names for an issue, optional
413413
* @param createdAt the date the issue was created at, optional
414414
* @param dueDate the due date, optional
415-
* @param mergeRequestToResolveId the IID of a merge request in which to resolve all issues. This will fill the issue with a default
415+
* @param mergeRequestToResolveId the IID of a merge request in which to resolve all issues. This will fill the issue with a default
416416
* description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values. Optional
417-
* @param discussionToResolveId the ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved.
417+
* @param discussionToResolveId the ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved.
418418
* Use in combination with merge_request_to_resolve_discussions_of. Optional
419419
* @return an instance of Issue
420420
* @throws GitLabApiException if any exception occurs
@@ -434,7 +434,7 @@ public Issue createIssue(Object projectIdOrPath, String title, String descriptio
434434
.withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId)
435435
.withParam("discussion_to_resolve", discussionToResolveId);
436436
Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "issues");
437-
return (response.readEntity(Issue.class));
437+
return (response.readEntity(Issue.class));
438438
}
439439

440440
/**
@@ -453,9 +453,9 @@ public Issue closeIssue(Object projectIdOrPath, Integer issueIid) throws GitLabA
453453
throw new RuntimeException("issue IID cannot be null");
454454
}
455455

456-
GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.CLOSE);
456+
GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.CLOSE);
457457
Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
458-
return (response.readEntity(Issue.class));
458+
return (response.readEntity(Issue.class));
459459
}
460460

461461
/**
@@ -477,7 +477,7 @@ public Issue closeIssue(Object projectIdOrPath, Integer issueIid) throws GitLabA
477477
* @return an instance of the updated Issue
478478
* @throws GitLabApiException if any exception occurs
479479
*/
480-
public Issue updateIssue(Object projectIdOrPath, Integer issueIid, String title, String description, Boolean confidential, List<Integer> assigneeIds,
480+
public Issue updateIssue(Object projectIdOrPath, Integer issueIid, String title, String description, Boolean confidential, List<Integer> assigneeIds,
481481
Integer milestoneId, String labels, StateEvent stateEvent, Date updatedAt, Date dueDate) throws GitLabApiException {
482482

483483
if (issueIid == null) {
@@ -495,7 +495,7 @@ public Issue updateIssue(Object projectIdOrPath, Integer issueIid, String title,
495495
.withParam("updated_at", updatedAt)
496496
.withParam("due_date", dueDate);
497497
Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
498-
return (response.readEntity(Issue.class));
498+
return (response.readEntity(Issue.class));
499499
}
500500

501501
/**
@@ -541,9 +541,9 @@ public void deleteIssue(Object projectIdOrPath, Integer issueIid) throws GitLabA
541541

542542
/**
543543
* Sets an estimated time of work in this issue
544-
*
544+
*
545545
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate</code></pre>
546-
*
546+
*
547547
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
548548
* @param issueIid the internal ID of a project's issue
549549
* @param duration estimated time in seconds
@@ -556,9 +556,9 @@ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, int dura
556556

557557
/**
558558
* Sets an estimated time of work in this issue
559-
*
559+
*
560560
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate</code></pre>
561-
*
561+
*
562562
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
563563
* @param issueIid the internal ID of a project's issue
564564
* @param duration Human readable format, e.g. 3h30m
@@ -571,9 +571,9 @@ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, String d
571571

572572
/**
573573
* Sets an estimated time of work in this issue
574-
*
574+
*
575575
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate</code></pre>
576-
*
576+
*
577577
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
578578
* @param issueIid the internal ID of a project's issue
579579
* @param duration set the estimate of time to this duration
@@ -596,9 +596,9 @@ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, Duration
596596

597597
/**
598598
* Resets the estimated time for this issue to 0 seconds.
599-
*
599+
*
600600
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_time_estimate</code></pre>
601-
*
601+
*
602602
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
603603
* @param issueIid the internal ID of a project's issue
604604
* @return a TimeSTats instance
@@ -617,9 +617,9 @@ public TimeStats resetEstimatedTime(Object projectIdOrPath, Integer issueIid) th
617617

618618
/**
619619
* Adds spent time for this issue
620-
*
620+
*
621621
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time</code></pre>
622-
*
622+
*
623623
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
624624
* @param issueIid the internal ID of a project's issue
625625
* @param duration the duration in seconds
@@ -632,9 +632,9 @@ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, int dura
632632

633633
/**
634634
* Adds spent time for this issue
635-
*
635+
*
636636
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time</code></pre>
637-
*
637+
*
638638
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
639639
* @param issueIid the internal ID of a project's issue
640640
* @param duration Human readable format, e.g. 3h30m
@@ -647,9 +647,9 @@ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, String d
647647

648648
/**
649649
* Adds spent time for this issue
650-
*
650+
*
651651
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time</code></pre>
652-
*
652+
*
653653
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
654654
* @param issueIid the internal ID of a project's issue
655655
* @param duration the duration of time spent
@@ -672,9 +672,9 @@ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, Duration
672672

673673
/**
674674
* Resets the total spent time for this issue to 0 seconds.
675-
*
675+
*
676676
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_spent_time</code></pre>
677-
*
677+
*
678678
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
679679
* @param issueIid the internal ID of a project's issue
680680
* @return a TimeSTats instance
@@ -693,9 +693,9 @@ public TimeStats resetSpentTime(Object projectIdOrPath, Integer issueIid) throws
693693

694694
/**
695695
* Get time tracking stats.
696-
*
696+
*
697697
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/time_stats</code></pre>
698-
*
698+
*
699699
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
700700
* @param issueIid the internal ID of a project's issue
701701
* @return a TimeStats instance
@@ -983,9 +983,25 @@ public IssuesStatistics getGroupIssuesStatistics(Object groupIdOrPath, IssuesSta
983983
return (response.readEntity(IssuesStatistics.class));
984984
}
985985

986+
/**
987+
* Gets issues count statistics for given project.
988+
*
989+
* <pre><code>GitLab Endpoint: GET /projects/:projectId/issues_statistics</code></pre>
990+
*
991+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
992+
* @param filter {@link IssuesStatisticsFilter} a IssuesStatisticsFilter instance with the filter settings.
993+
* @return an IssuesStatistics instance with the statistics for the matched issues
994+
* @throws GitLabApiException if any exception occurs
995+
*/
996+
public IssuesStatistics geProjectIssuesStatistics(Object projectIdOrPath, IssuesStatisticsFilter filter) throws GitLabApiException {
997+
GitLabApiForm formData = filter.getQueryParams();
998+
Response response = get(Response.Status.OK, formData.asMap(), "projects", this.getProjectIdOrPath(projectIdOrPath), "issues_statistics");
999+
return (response.readEntity(IssuesStatistics.class));
1000+
}
1001+
9861002
/**
9871003
* <p>Moves an issue to a different project. If the target project equals the source project or
988-
* the user has insufficient permissions to move an issue, error 400 together with an
1004+
* the user has insufficient permissions to move an issue, error 400 together with an
9891005
* explaining error message is returned.</p>
9901006
*
9911007
* <p>If a given label and/or milestone with the same name also exists in the target project,
@@ -1004,5 +1020,5 @@ public Issue moveIssue(Object projectIdOrPath, Integer issueIid, Object toProjec
10041020
Response response = post(Response.Status.OK, formData,
10051021
"projects", this.getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "move");
10061022
return (response.readEntity(Issue.class));
1007-
}
1023+
}
10081024
}

0 commit comments

Comments
 (0)