StatisticsController

public struct StatisticsController : RouteCollection

Controller with endpoints that return statistics for build related data

  • Returns the routes supported by this Controller. All the routes are in the v1/statistics path

    Throws

    An Error if something goes wrong

    Declaration

    Swift

    public func boot(routes: RoutesBuilder) throws

    Parameters

    routes

    RoutesBuilder to which the routes will be added

  • Endpoint that returns a list of DayCount which includes the sum of errors and builds during a given day

    • Method: GET
    • Route: /v1/statistics/build/count?days=14
    • Request parameters

      • days. How many days to include in the past, starting from the current date
    • Response:

      [
      {
       "id": "2021-07-14",
       "builds": 197,
       "errors": 4,
      },
      ...
      ]
      

    Declaration

    Swift

    public func buildCounts(req: Request) throws -> EventLoopFuture<[DayCount]>
  • Endpoint that returns the paginated list of BuildStatusResult to minimize payload size when many statuses are required

    • Method: GET
    • Route: /v1/statistics/build/status?page=1&per=10
    • Request parameters

      • page. Optional. Page number to fetch. Default is 1
      • per. Optional. Number of items to fetch per page. Default is 10
    • Response:

      {
      "metadata": {
        "per": 10,
        "total": 100,
        "page": 2
      },
      "items": [
       {
         "id": "MyMac_34580469-5792-40F3-BEFB-7C5925996F23_1",
         "buildStatus": "succeeded",
       },
       ...
      ]
      }
      

    Declaration

    Swift

    public func buildStatus(req: Request) throws -> EventLoopFuture<Page<BuildStatusResult>>
  • Endpoint that returns a list of DayBuildTime which includes the build times for a number of procentiles of the builds and the total build time for each day, in seconds. The durationPX fields indicate that X % of the builds of the a day had a duration less or equal to the value.

    • Method: GET
    • Route: /v1/statistics/build/time?days=14
    • Request parameters

      • days. How many days to include in the past, starting from the current date
    • Response:

      [
      {
       "id": "2021-07-26",
       "durationP50": 18473.21,
       "durationP95": 54431313.32
       "totalDuration": 10983982398.549,
      },
      ...
      ]
      

    Declaration

    Swift

    public func buildTimes(req: Request) throws -> EventLoopFuture<[DayBuildTime]>