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

Feature: gitlab service widget #4317

Merged
merged 8 commits into from
Nov 22, 2024

Conversation

UrsKroell
Copy link
Contributor

Proposed change

This adds a widget for Gitlab. It is able to list the amount of events as well as the open issues and open merge requests

grafik

Closes #3406

Type of change

  • New service widget
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation only
  • Other (please explain)

Checklist:

  • If applicable, I have added corresponding documentation changes.
  • If applicable, I have reviewed the feature and / or service widget guidelines.
  • I have checked that all code style checks pass using pre-commit hooks and linting checks.
  • If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.

@UrsKroell
Copy link
Contributor Author

API output for /api/v4/events

[
    {
        "id": 36,
        "project_id": 7,
        "action_name": "closed",
        "target_id": 2,
        "target_iid": 2,
        "target_type": "Issue",
        "author_id": 34,
        "target_title": "dddddddddd",
        "created_at": "2024-11-15T22:20:57.593Z",
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "imported": false,
        "imported_from": "none",
        "author_username": "user"
    },
    {
        "id": 35,
        "project_id": 7,
        "action_name": "opened",
        "target_id": 2,
        "target_iid": 2,
        "target_type": "Issue",
        "author_id": 34,
        "target_title": "dddddddddd",
        "created_at": "2024-11-15T22:20:36.887Z",
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "imported": false,
        "imported_from": "none",
        "author_username": "user"
    },
    {
        "id": 34,
        "project_id": 7,
        "action_name": "opened",
        "target_id": 1,
        "target_iid": 1,
        "target_type": "Issue",
        "author_id": 34,
        "target_title": "Issue 1",
        "created_at": "2024-11-15T21:46:14.248Z",
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "imported": false,
        "imported_from": "none",
        "author_username": "user"
    },
    {
        "id": 33,
        "project_id": 7,
        "action_name": "pushed to",
        "target_id": null,
        "target_iid": null,
        "target_type": null,
        "author_id": 34,
        "target_title": null,
        "created_at": "2024-11-15T21:22:14.015Z",
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "imported": false,
        "imported_from": "none",
        "push_data": {
            "commit_count": 1,
            "action": "pushed",
            "ref_type": "branch",
            "commit_from": "4a322bef03607e2aa9e70d88d568f7df464d1882",
            "commit_to": "e305e9d0e8a01524c8bbdfadcf15333c96b77fc7",
            "ref": "main",
            "commit_title": "Add new file",
            "ref_count": null
        },
        "author_username": "user"
    }
]

@UrsKroell
Copy link
Contributor Author

API output for /api/v4/issues?state=opened

[
    {
        "id": 1,
        "iid": 1,
        "project_id": 7,
        "title": "Issue 1",
        "description": "This is just an issue",
        "state": "opened",
        "created_at": "2024-11-15T21:46:13.978Z",
        "updated_at": "2024-11-15T21:46:13.978Z",
        "closed_at": null,
        "closed_by": null,
        "labels": [],
        "milestone": null,
        "assignees": [
            {
                "id": 34,
                "username": "user",
                "name": "User N",
                "state": "active",
                "locked": false,
                "avatar_url": null,
                "web_url": "http://gitlab.example.com/user"
            }
        ],
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "type": "ISSUE",
        "assignee": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "user_notes_count": 0,
        "merge_requests_count": 0,
        "upvotes": 0,
        "downvotes": 0,
        "due_date": "2025-09-12",
        "confidential": false,
        "discussion_locked": null,
        "issue_type": "issue",
        "web_url": "http://gitlab.example.com/user/gitlab-openapi/-/issues/1",
        "time_stats": {
            "time_estimate": 0,
            "total_time_spent": 0,
            "human_time_estimate": null,
            "human_total_time_spent": null
        },
        "task_completion_status": {
            "count": 0,
            "completed_count": 0
        },
        "has_tasks": true,
        "task_status": "0 of 0 checklist items completed",
        "_links": {
            "self": "http://gitlab.example.com/api/v4/projects/7/issues/1",
            "notes": "http://gitlab.example.com/api/v4/projects/7/issues/1/notes",
            "award_emoji": "http://gitlab.example.com/api/v4/projects/7/issues/1/award_emoji",
            "project": "http://gitlab.example.com/api/v4/projects/7",
            "closed_as_duplicate_of": null
        },
        "references": {
            "short": "#1",
            "relative": "#1",
            "full": "user/gitlab-openapi#1"
        },
        "severity": "UNKNOWN",
        "moved_to_id": null,
        "imported": false,
        "imported_from": "none",
        "service_desk_reply_to": null
    }
]

@UrsKroell
Copy link
Contributor Author

API output for /api/v4/merge_requests?state=opened

[
    {
        "id": 1,
        "iid": 1,
        "project_id": 4,
        "title": "Feature/cool-feature",
        "description": "Adds cool-feature",
        "state": "opened",
        "created_at": "2024-11-22T00:51:31.181Z",
        "updated_at": "2024-11-22T00:51:33.478Z",
        "merged_by": null,
        "merge_user": null,
        "merged_at": null,
        "closed_by": null,
        "closed_at": null,
        "target_branch": "main",
        "source_branch": "feature/cool-feature",
        "user_notes_count": 0,
        "upvotes": 0,
        "downvotes": 0,
        "author": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "assignees": [
            {
                "id": 34,
                "username": "user",
                "name": "User N",
                "state": "active",
                "locked": false,
                "avatar_url": null,
                "web_url": "http://gitlab.example.com/user"
            }
        ],
        "assignee": {
            "id": 34,
            "username": "user",
            "name": "User N",
            "state": "active",
            "locked": false,
            "avatar_url": null,
            "web_url": "http://gitlab.example.com/user"
        },
        "reviewers": [
            {
                "id": 34,
                "username": "user",
                "name": "User N",
                "state": "active",
                "locked": false,
                "avatar_url": null,
                "web_url": "http://gitlab.example.com/user"
            }
        ],
        "source_project_id": 4,
        "target_project_id": 4,
        "labels": [],
        "draft": false,
        "imported": false,
        "imported_from": "none",
        "work_in_progress": false,
        "milestone": null,
        "merge_when_pipeline_succeeds": false,
        "merge_status": "can_be_merged",
        "detailed_merge_status": "mergeable",
        "merge_after": null,
        "sha": "b86a6d6c91ef014368a959cd3c3ea890ca8ecf19",
        "merge_commit_sha": null,
        "squash_commit_sha": null,
        "discussion_locked": null,
        "should_remove_source_branch": null,
        "force_remove_source_branch": false,
        "prepared_at": "2024-11-22T00:51:33.472Z",
        "reference": "!1",
        "references": {
            "short": "!1",
            "relative": "!1",
            "full": "user/cool-repo!1"
        },
        "web_url": "http://gitlab.example.com/user/cool-repo/-/merge_requests/1",
        "time_stats": {
            "time_estimate": 0,
            "total_time_spent": 0,
            "human_time_estimate": null,
            "human_total_time_spent": null
        },
        "squash": false,
        "squash_on_merge": false,
        "task_completion_status": {
            "count": 0,
            "completed_count": 0
        },
        "has_conflicts": false,
        "blocking_discussions_resolved": true
    }
]

@shamoon shamoon changed the title Feature/gitlab widget Feature: gitlab service widget Nov 22, 2024
@shamoon
Copy link
Collaborator

shamoon commented Nov 22, 2024

Thanks. Is there an obvious way to reduce the amount of requests here without nuking the value of the widget? I.e. some other endpoint?

Copy link
Collaborator

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look and we should use https://docs.gitlab.com/ee/api/users.html#get-a-count-of-a-users-projects-groups-issues-and-merge-requests . I realize it's not a perfect replacement for what you had but fewer requests is an important target to aim for.

I just pushed the changes rather than make all of the suggestions. I'll hold off on merging until I hear back, and no hard feelings if you dont agree with the choice.

Thanks for contributing

Screenshot 2024-11-21 at 7 09 19 PM

@shamoon shamoon enabled auto-merge (squash) November 22, 2024 04:51
@UrsKroell
Copy link
Contributor Author

No everything's good. That's the better endpoint to use. I guess I just overlooked it.

So from my side it's good to go

@shamoon shamoon merged commit 2b8647b into gethomepage:dev Nov 22, 2024
5 checks passed
@UrsKroell UrsKroell deleted the feature/gitlab-widget branch November 22, 2024 15:27
@UrsKroell
Copy link
Contributor Author

Thanks for your hard work on the project 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants