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

[API] /api/user/repos include last build status #747

Open
nitn3lav opened this issue Feb 4, 2022 · 1 comment
Open

[API] /api/user/repos include last build status #747

nitn3lav opened this issue Feb 4, 2022 · 1 comment
Labels
enhancement improve existing features server

Comments

@nitn3lav
Copy link
Contributor

nitn3lav commented Feb 4, 2022

To show the current build status on the repos page it is necessary to have some basic information about the latest build of each repo. While it would generally be possible to retrieve this info using the GET /api/repos/<owner>/<repo>/builds endpoint this would lead to a unnecessarily large number of requests. Therefore I propose to directly add this data to GET /api/user/repos. I can currently think of these options to do so:

  1. add info about the last build:
[
    {
        "id": 5,
        "owner": "test",
        "name": "123",
        "full_name": "test/123",
        "link_url": "https://git.example.com/test/123",
        // new:
        "last_build": {
            "id": 107,
            "number": 19,
            "author": "test",
            "event": "push",
            "status": "success",
            "enqueued_at": 1643933634,
            "created_at": 1643933634,
            "started_at": 1643938125,
            "finished_at": 1643939241,
            "commit": "7fe7b02400c1c598a3f49b65c5693e4e41554056",
            "branch": "main",
            "message": "commit message",
            "timestamp": 1643933633,
            "author_avatar": "https://git.example.com/avatars/fa93386cdc60183ae3a861c45170bc6a",
            "link_url": "https://git.piored.de/vidre/transcoding-server/commit/7fe7b02400c1c598a3f49b65c5693e4e41554056",
            "changed_files": [
                "testfile-1"
            ],
            ...
        },
        ...
    },
    ...
]
  1. alternatively this could be the last build on the default barnch (usually master or main)

  2. add an array of the latest builds for each branch:

[
    {
        "id": 5,
        "owner": "test",
        "name": "123",
        "full_name": "test/123",
        "link_url": "https://git.example.com/test/123",
        // new:
        "last_builds": [
            {
                "id": 107,
                "number": 19,
                "author": "test",
                "event": "push",
                "status": "success",
                "enqueued_at": 1643933634,
                "created_at": 1643933634,
                "started_at": 1643938125,
                "finished_at": 1643939241,
                "commit": "7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "branch": "main", // dafault branch
                "message": "commit message",
                "timestamp": 1643933633,
                "author_avatar": "https://git.example.com/avatars/fa93386cdc60183ae3a861c45170bc6a",
                "link_url": "https://git.piored.de/vidre/transcoding-server/commit/7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "changed_files": [
                    "testfile-1"
                ],
                ...
            },
            // if option 5 is chosen, this is only included if the last build was not on the default branch
            {
                "id": 107,
                "number": 19,
                "author": "test",
                "event": "push",
                "status": "success",
                "enqueued_at": 1643933634,
                "created_at": 1643933634,
                "started_at": 1643938125,
                "finished_at": 1643939241,
                "commit": "a6e350241cc1c598ada90b65cee8f3e4e41abf3f7",
                "branch": "new-feature-branch", // some branch other than the default `main`
                "message": "commit message",
                "timestamp": 1643933633,
                "author_avatar": "https://git.example.com/avatars/fa93386cdc60183ae3a861c45170bc6a",
                "link_url": "https://git.piored.de/vidre/transcoding-server/commit/7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "changed_files": [
                    "testfile-2"
                ],
                ...
            },
            ...
    },
    ...
]
  1. a map with the branch as key could be used instead of an array:
[
    {
        "id": 5,
        "owner": "test",
        "name": "123",
        "full_name": "test/123",
        "link_url": "https://git.example.com/test/123",
        // new:
        "last_builds": {
            "main": { // default branch
                "id": 107,
                "number": 19,
                "author": "test",
                "event": "push",
                "status": "success",
                "enqueued_at": 1643933634,
                "created_at": 1643933634,
                "started_at": 1643938125,
                "finished_at": 1643939241,
                "commit": "7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "branch": "main", // dafault branch
                "message": "commit message",
                "timestamp": 1643933633,
                "author_avatar": "https://git.example.com/avatars/fa93386cdc60183ae3a861c45170bc6a",
                "link_url": "https://git.piored.de/vidre/transcoding-server/commit/7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "changed_files": [
                    "testfile-1"
                ],
                ...
            },
            // if option 5 is chosen, this is only included if the last build was not on the default branch
            "new-feature-branch": { // some branch other than the default `main`
                "id": 107,
                "number": 19,
                "author": "test",
                "event": "push",
                "status": "success",
                "enqueued_at": 1643933634,
                "created_at": 1643933634,
                "started_at": 1643938125,
                "finished_at": 1643939241,
                "commit": "a6e350241cc1c598ada90b65cee8f3e4e41abf3f7",
                "branch": "new-feature-branch", // some branch other than the default `main`
                "message": "commit message",
                "timestamp": 1643933633,
                "author_avatar": "https://git.example.com/avatars/fa93386cdc60183ae3a861c45170bc6a",
                "link_url": "https://git.piored.de/vidre/transcoding-server/commit/7fe7b02400c1c598a3f49b65c5693e4e41554056",
                "changed_files": [
                    "testfile-2"
                ],
                ...
            },
            ...
    },
    ...
]
  1. Instead of including the latest build status for every branch it would also be possible to only include the info for the default branch and if applicable the latest build on a non-default branch. This could reduce data usage for repos with many branches.

Options 3, 4 and 5 would allow users to select in the settings if they want to see the status of the latest build or the latest build on the default branch (master or main).

@nitn3lav nitn3lav changed the title [API] /api/repos/<owner>/<repo>/builds include last build status [API] /api/repos include last build status Feb 4, 2022
@nitn3lav nitn3lav changed the title [API] /api/repos include last build status [API] /api/user/repos include last build status Feb 4, 2022
@anbraten
Copy link
Member

Instead of including the data, I would add a new endpoint to return the last pipeline of a specific repo. The UI can simply combine this data.

@qwerty287 qwerty287 added server enhancement improve existing features labels Feb 10, 2024
@anbraten anbraten mentioned this issue Jun 24, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features server
Projects
None yet
Development

No branches or pull requests

3 participants