@backstage-community/plugin-cicd-statistics 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/alpha/entityContent.esm.js +1 -1
  3. package/dist/alpha/entityContent.esm.js.map +1 -1
  4. package/dist/alpha.d.ts +15 -11
  5. package/dist/alpha.esm.js.map +1 -1
  6. package/dist/apis/cicd-statistics.esm.js.map +1 -1
  7. package/dist/apis/types.esm.js.map +1 -1
  8. package/dist/charts/colors.esm.js.map +1 -1
  9. package/dist/charts/logic/analysis.esm.js.map +1 -1
  10. package/dist/charts/logic/conversions.esm.js +1 -1
  11. package/dist/charts/logic/conversions.esm.js.map +1 -1
  12. package/dist/charts/logic/count-builds-per-day.esm.js.map +1 -1
  13. package/dist/charts/logic/daily-summary.esm.js.map +1 -1
  14. package/dist/charts/logic/finalize-stage.esm.js.map +1 -1
  15. package/dist/charts/logic/utils.esm.js.map +1 -1
  16. package/dist/charts/stage-chart.esm.js +1 -1
  17. package/dist/charts/stage-chart.esm.js.map +1 -1
  18. package/dist/charts/status-chart.esm.js.map +1 -1
  19. package/dist/charts/zoom.esm.js.map +1 -1
  20. package/dist/components/button-switch.esm.js.map +1 -1
  21. package/dist/components/chart-filters.esm.js.map +1 -1
  22. package/dist/components/duration-slider.esm.js.map +1 -1
  23. package/dist/components/label.esm.js.map +1 -1
  24. package/dist/components/progress.esm.js.map +1 -1
  25. package/dist/components/toggle.esm.js.map +1 -1
  26. package/dist/components/utils.esm.js.map +1 -1
  27. package/dist/entity-page.esm.js.map +1 -1
  28. package/dist/hooks/use-cicd-configuration.esm.js.map +1 -1
  29. package/dist/hooks/use-cicd-statistics-api.esm.js.map +1 -1
  30. package/dist/hooks/use-cicd-statistics.esm.js.map +1 -1
  31. package/dist/index.d.ts +0 -1
  32. package/dist/plugin.esm.js.map +1 -1
  33. package/dist/utils/api.esm.js.map +1 -1
  34. package/dist/utils/stage-names.esm.js.map +1 -1
  35. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage-community/plugin-cicd-statistics
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6b61b33: Backstage version bump to v1.50.2
8
+
9
+ ## 0.15.1
10
+
11
+ ### Patch Changes
12
+
13
+ - a7f3f99: Backstage version bump to v1.48.4
14
+
3
15
  ## 0.15.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { convertLegacyRouteRef, compatWrapper } from '@backstage/core-compat-api';
2
+ import { compatWrapper, convertLegacyRouteRef } from '@backstage/core-compat-api';
3
3
  import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
4
4
  import { rootCatalogCicdStatsRouteRef } from '../plugin.esm.js';
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"entityContent.esm.js","sources":["../../src/alpha/entityContent.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { rootCatalogCicdStatsRouteRef } from '../plugin';\n\n/**\n * @alpha\n */\nexport const entityCicdChartsContent = EntityContentBlueprint.make({\n name: 'entity',\n params: {\n path: 'cicd-statistics',\n title: 'CI/CD Statistics',\n filter: 'kind:component',\n routeRef: convertLegacyRouteRef(rootCatalogCicdStatsRouteRef),\n loader: () =>\n import('../entity-page').then(m =>\n compatWrapper(<m.EntityPageCicdCharts />),\n ),\n },\n});\n"],"names":[],"mappings":";;;;;AAyBa,MAAA,uBAAA,GAA0B,uBAAuB,IAAK,CAAA;AAAA,EACjE,IAAM,EAAA,QAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,iBAAA;AAAA,IACN,KAAO,EAAA,kBAAA;AAAA,IACP,MAAQ,EAAA,gBAAA;AAAA,IACR,QAAA,EAAU,sBAAsB,4BAA4B,CAAA;AAAA,IAC5D,MAAQ,EAAA,MACN,OAAO,uBAAgB,CAAE,CAAA,IAAA;AAAA,MAAK,OAC5B,aAAc,iBAAA,GAAA,CAAC,CAAE,CAAA,oBAAA,EAAF,EAAuB,CAAE;AAAA;AAC1C;AAEN,CAAC;;;;"}
1
+ {"version":3,"file":"entityContent.esm.js","sources":["../../src/alpha/entityContent.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { rootCatalogCicdStatsRouteRef } from '../plugin';\n\n/**\n * @alpha\n */\nexport const entityCicdChartsContent = EntityContentBlueprint.make({\n name: 'entity',\n params: {\n path: 'cicd-statistics',\n title: 'CI/CD Statistics',\n filter: 'kind:component',\n routeRef: convertLegacyRouteRef(rootCatalogCicdStatsRouteRef),\n loader: () =>\n import('../entity-page').then(m =>\n compatWrapper(<m.EntityPageCicdCharts />),\n ),\n },\n});\n"],"names":[],"mappings":";;;;;AAyBO,MAAM,uBAAA,GAA0B,uBAAuB,IAAA,CAAK;AAAA,EACjE,IAAA,EAAM,QAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,iBAAA;AAAA,IACN,KAAA,EAAO,kBAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,QAAA,EAAU,sBAAsB,4BAA4B,CAAA;AAAA,IAC5D,MAAA,EAAQ,MACN,OAAO,uBAAgB,CAAA,CAAE,IAAA;AAAA,MAAK,OAC5B,aAAA,iBAAc,GAAA,CAAC,CAAA,CAAE,oBAAA,EAAF,EAAuB,CAAE;AAAA;AAC1C;AAEN,CAAC;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- /// <reference types="react" />
2
1
  import * as _backstage_catalog_model from '@backstage/catalog-model';
3
2
  import * as react from 'react';
4
- import * as _backstage_plugin_catalog_react_alpha from '@backstage/plugin-catalog-react/alpha';
3
+ import * as _backstage_filter_predicates from '@backstage/filter-predicates';
5
4
  import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
6
5
 
7
6
  /**
@@ -16,14 +15,16 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
16
15
  config: {
17
16
  path: string | undefined;
18
17
  title: string | undefined;
19
- filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
18
+ filter: _backstage_filter_predicates.FilterPredicate | undefined;
20
19
  group: string | false | undefined;
20
+ icon: string | undefined;
21
21
  };
22
22
  configInput: {
23
- filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
24
- title?: string | undefined;
25
23
  path?: string | undefined;
24
+ title?: string | undefined;
25
+ filter?: _backstage_filter_predicates.FilterPredicate | undefined;
26
26
  group?: string | false | undefined;
27
+ icon?: string | undefined;
27
28
  };
28
29
  output: _backstage_frontend_plugin_api.ExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
29
30
  optional: true;
@@ -33,18 +34,21 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
33
34
  optional: true;
34
35
  }> | _backstage_frontend_plugin_api.ExtensionDataRef<string, "catalog.entity-content-title", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<string, "catalog.entity-content-group", {
35
36
  optional: true;
37
+ }> | _backstage_frontend_plugin_api.ExtensionDataRef<string | react.ReactElement<any, string | react.JSXElementConstructor<any>>, "catalog.entity-content-icon", {
38
+ optional: true;
36
39
  }>;
37
40
  inputs: {};
38
41
  params: {
39
- defaultPath?: [Error: "Use the 'path' param instead"] | undefined;
42
+ defaultPath?: [Error: `Use the 'path' param instead`];
40
43
  path: string;
41
- defaultTitle?: [Error: "Use the 'title' param instead"] | undefined;
44
+ defaultTitle?: [Error: `Use the 'title' param instead`];
42
45
  title: string;
43
- defaultGroup?: [Error: "Use the 'group' param instead"] | undefined;
44
- group?: (string & {}) | "overview" | "documentation" | "development" | "deployment" | "operation" | "observability" | undefined;
46
+ defaultGroup?: [Error: `Use the 'group' param instead`];
47
+ group?: ("development" | "overview" | "documentation" | "deployment" | "operation" | "observability") | (string & {});
48
+ icon?: string | react.ReactElement;
45
49
  loader: () => Promise<JSX.Element>;
46
- routeRef?: _backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams> | undefined;
47
- filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
50
+ routeRef?: _backstage_frontend_plugin_api.RouteRef;
51
+ filter?: string | _backstage_filter_predicates.FilterPredicate | ((entity: _backstage_catalog_model.Entity) => boolean);
48
52
  };
49
53
  }>;
50
54
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { convertLegacyRouteRefs } from '@backstage/core-compat-api';\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport { entityCicdChartsContent } from './alpha/index';\nimport { rootCatalogCicdStatsRouteRef } from './plugin';\n\n/**\n * @alpha\n */\nexport default createFrontendPlugin({\n pluginId: 'cicd-statistics',\n routes: convertLegacyRouteRefs({\n entityContent: rootCatalogCicdStatsRouteRef,\n }),\n extensions: [entityCicdChartsContent],\n});\n"],"names":[],"mappings":";;;;;AAuBA,YAAe,oBAAqB,CAAA;AAAA,EAClC,QAAU,EAAA,iBAAA;AAAA,EACV,QAAQ,sBAAuB,CAAA;AAAA,IAC7B,aAAe,EAAA;AAAA,GAChB,CAAA;AAAA,EACD,UAAA,EAAY,CAAC,uBAAuB;AACtC,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { convertLegacyRouteRefs } from '@backstage/core-compat-api';\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport { entityCicdChartsContent } from './alpha/index';\nimport { rootCatalogCicdStatsRouteRef } from './plugin';\n\n/**\n * @alpha\n */\nexport default createFrontendPlugin({\n pluginId: 'cicd-statistics',\n routes: convertLegacyRouteRefs({\n entityContent: rootCatalogCicdStatsRouteRef,\n }),\n extensions: [entityCicdChartsContent],\n});\n"],"names":[],"mappings":";;;;;AAuBA,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,iBAAA;AAAA,EACV,QAAQ,sBAAA,CAAuB;AAAA,IAC7B,aAAA,EAAe;AAAA,GAChB,CAAA;AAAA,EACD,UAAA,EAAY,CAAC,uBAAuB;AACtC,CAAC,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"cicd-statistics.esm.js","sources":["../../src/apis/cicd-statistics.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { CicdStatisticsApi } from './types';\n\n/** @public */\nexport const cicdStatisticsApiRef = createApiRef<CicdStatisticsApi>({\n id: 'cicd-statistics-api',\n});\n"],"names":[],"mappings":";;AAoBO,MAAM,uBAAuB,YAAgC,CAAA;AAAA,EAClE,EAAI,EAAA;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"cicd-statistics.esm.js","sources":["../../src/apis/cicd-statistics.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { CicdStatisticsApi } from './types';\n\n/** @public */\nexport const cicdStatisticsApiRef = createApiRef<CicdStatisticsApi>({\n id: 'cicd-statistics-api',\n});\n"],"names":[],"mappings":";;AAoBO,MAAM,uBAAuB,YAAA,CAAgC;AAAA,EAClE,EAAA,EAAI;AACN,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.esm.js","sources":["../../src/apis/types.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * This is a generic enum of build statuses.\n *\n * If all of these aren't applicable to the underlying CI/CD, these can be\n * configured to be hidden, using the `availableStatuses` in `CicdConfiguration`.\n *\n * @public\n */\nexport type FilterStatusType =\n | 'unknown'\n | 'enqueued'\n | 'scheduled'\n | 'running'\n | 'aborted'\n | 'succeeded'\n | 'failed'\n | 'stalled'\n | 'expired';\n\n/**\n * @public\n */\nexport const statusTypes: Array<FilterStatusType> = [\n 'succeeded',\n 'failed',\n 'enqueued',\n 'scheduled',\n 'running',\n 'aborted',\n 'stalled',\n 'expired',\n 'unknown',\n];\n\n/**\n * The branch enum of either 'master' or 'branch' (or possibly the meta 'all').\n *\n * The concept of what constitutes a master branch is generic. It might be called\n * something like 'release' or 'main' or 'trunk' in the underlying CI/CD system,\n * which is then up to the Api to map accordingly.\n *\n * @public\n */\nexport type FilterBranchType = 'master' | 'branch';\n\n/**\n * @public\n */\nexport type TriggerReason =\n /** Triggered by source code management, e.g. a Github hook */\n | 'scm'\n /** Triggered manually */\n | 'manual'\n /** Triggered internally (non-scm, or perhaps after being delayed/enqueued) */\n | 'internal'\n /** Triggered for some other reason */\n | 'other';\n\n/**\n * @public\n */\nexport const triggerReasons: Array<TriggerReason> = [\n 'scm',\n 'manual',\n 'internal',\n 'other',\n];\n\n/**\n * A Stage is a part of either a Build or a parent Stage.\n *\n * This may be called things like Stage or Step or Task in CI/CD systems, but is\n * generic here. There's also no concept of parallelism which might exist within\n * some stages.\n *\n * @public\n */\nexport interface Stage {\n name: string;\n\n /** The status of the stage */\n status: FilterStatusType;\n\n /** Stage duration in milliseconds */\n duration: number;\n\n /** Sub stages within this stage */\n stages?: Array<Stage>;\n}\n\n/**\n * Generic Build type.\n *\n * A build has e.g. a build type (master/branch), a status and (possibly) sub stages.\n *\n * @public\n */\nexport interface Build {\n raw?: unknown;\n\n /** Build id */\n id: string;\n\n /** The reason this build was started */\n triggeredBy?: TriggerReason;\n\n /** The status of the build */\n status: FilterStatusType;\n\n /** Branch type */\n branchType: FilterBranchType;\n\n /** Time when the build started */\n requestedAt: Date;\n\n /** The overall duration of the build */\n duration: number;\n\n /** Top-level build stages */\n stages: Array<Stage>;\n}\n\n/**\n * Helper type which is a Build with a certain typed 'raw' field.\n *\n * This can be useful in an Api to use while mapping internal data structures\n * (raw) into generic builds.\n *\n * @public\n */\nexport type BuildWithRaw<T = any> = Build & {\n raw: T;\n};\n\n/**\n * Chart type.\n *\n * Values are:\n * * `duration`: shows an area chart of the duration over time\n * * `count`: shows a bar chart of the number of build per day\n *\n * @public\n */\nexport type ChartType = 'duration' | 'count';\n\n/**\n * Chart types.\n *\n * @public\n */\nexport type ChartTypes = Array<ChartType>;\n\n/**\n * Default settings for the fetching options and view options.\n *\n * These are all optional, but can be overridden from the Api to whatever makes\n * most sense for that implementation.\n *\n * @public\n */\nexport interface CicdDefaults {\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType>;\n filterType: FilterBranchType | 'all';\n\n /** Lower-case all stage names (to potentially merge stages with different cases) */\n lowercaseNames: boolean;\n /** Normalize the from-to date range in all charts */\n normalizeTimeRange: boolean;\n /** Default collapse the stages with a max-duration below this value */\n collapsedLimit: number;\n /** Default hide stages with a max-duration below this value */\n hideLimit: number;\n /** Chart types per status */\n chartTypes: Record<FilterStatusType, ChartTypes>;\n}\n\n/**\n * A configuration interface which the Api must implement.\n *\n * When the UI for the CI/CD Statistics is loaded, it begins with fetching the\n * configuration before anything else.\n *\n * All of these fields are optional though, and will fallback to hard-coded defaults.\n *\n * @public\n */\nexport interface CicdConfiguration {\n /**\n * This field can be used to override what statuses are available\n */\n availableStatuses: ReadonlyArray<FilterStatusType>;\n\n /**\n * When transposing the list of builds into a tree of stages, the stage names\n * will be transformed through this function.\n *\n * Override this for a custom implementation. The default will try to remove\n * parent names off of child names, if they are prepended by them.\n *\n * For example; if a stage has the name 'Install' and a child stage has the\n * name 'Install - Fetch dependencies', the child name will be replaced with\n * 'Fetch dependencies'.\n */\n formatStageName: (parentNames: Array<string>, stageName: string) => string;\n\n /**\n * Default options for the UI\n */\n defaults: Partial<CicdDefaults>;\n}\n\n/**\n * If the Api implements support for aborting the fetching of builds, throw an\n * AbortError of this type (or any other error with name === 'AbortError').\n *\n * @public\n */\nexport class AbortError extends Error {}\n\n/**\n * The result type for `fetchBuilds`.\n *\n * @public\n */\nexport interface CicdState {\n builds: Array<Build>;\n}\n\n/**\n * When fetching, if applicable, the Api can feedback progress back to the UI.\n *\n * Use the `updateProgress(completed, total, started?)` to signal that\n * `completed` builds out of a `total` has finished. Optionally use the\n * `started` to signal how many builds have been started in total (i.e. at least\n * the amount of `completed`).\n *\n * This can be called at any rate. Rate limiting (debouncing) is implemented in\n * the UI.\n *\n * Optionally this can signal multiple progresses in several steps\n *\n * @public\n */\nexport interface UpdateProgress {\n (completed: number, total: number, started?: number): void;\n (\n steps: Array<{\n title: string;\n completed: number;\n total: number;\n started?: number;\n }>,\n ): void;\n}\n\n/**\n * When reading configuration, the Api can return a custom settings depending on\n * the entity being viewed.\n *\n * @public\n */\nexport interface GetConfigurationOptions {\n entity: Entity;\n}\n\n/**\n * When fetching, the Api should fetch build information about the `entity` and\n * respect the `timeFrom`, `timeTo`, `filterStatus` and `filterType`.\n *\n * Optionally implement support for `updateProgress` and `abortSignal` if\n * preferred.\n *\n * When the UI re-fetches, it will abort any previous fetching, so polling\n * `abortSignal.aborted`, and possibly throwing an `AbortError`, can be useful.\n *\n * @public\n */\nexport interface FetchBuildsOptions {\n entity: Entity;\n updateProgress: UpdateProgress;\n abortSignal: AbortSignal;\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType | 'all'>;\n filterType: FilterBranchType | 'all';\n}\n\n/**\n * The interface which is mapped to the `cicdStatisticsApiRef` which is used by\n * the UI.\n *\n * @public\n */\nexport interface CicdStatisticsApi {\n getConfiguration(\n options: GetConfigurationOptions,\n ): Promise<Partial<CicdConfiguration>>;\n fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;\n}\n"],"names":[],"mappings":"AAwCO,MAAM,WAAuC,GAAA;AAAA,EAClD,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AA6BO,MAAM,cAAuC,GAAA;AAAA,EAClD,KAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAyJO,MAAM,mBAAmB,KAAM,CAAA;AAAC;;;;"}
1
+ {"version":3,"file":"types.esm.js","sources":["../../src/apis/types.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * This is a generic enum of build statuses.\n *\n * If all of these aren't applicable to the underlying CI/CD, these can be\n * configured to be hidden, using the `availableStatuses` in `CicdConfiguration`.\n *\n * @public\n */\nexport type FilterStatusType =\n | 'unknown'\n | 'enqueued'\n | 'scheduled'\n | 'running'\n | 'aborted'\n | 'succeeded'\n | 'failed'\n | 'stalled'\n | 'expired';\n\n/**\n * @public\n */\nexport const statusTypes: Array<FilterStatusType> = [\n 'succeeded',\n 'failed',\n 'enqueued',\n 'scheduled',\n 'running',\n 'aborted',\n 'stalled',\n 'expired',\n 'unknown',\n];\n\n/**\n * The branch enum of either 'master' or 'branch' (or possibly the meta 'all').\n *\n * The concept of what constitutes a master branch is generic. It might be called\n * something like 'release' or 'main' or 'trunk' in the underlying CI/CD system,\n * which is then up to the Api to map accordingly.\n *\n * @public\n */\nexport type FilterBranchType = 'master' | 'branch';\n\n/**\n * @public\n */\nexport type TriggerReason =\n /** Triggered by source code management, e.g. a Github hook */\n | 'scm'\n /** Triggered manually */\n | 'manual'\n /** Triggered internally (non-scm, or perhaps after being delayed/enqueued) */\n | 'internal'\n /** Triggered for some other reason */\n | 'other';\n\n/**\n * @public\n */\nexport const triggerReasons: Array<TriggerReason> = [\n 'scm',\n 'manual',\n 'internal',\n 'other',\n];\n\n/**\n * A Stage is a part of either a Build or a parent Stage.\n *\n * This may be called things like Stage or Step or Task in CI/CD systems, but is\n * generic here. There's also no concept of parallelism which might exist within\n * some stages.\n *\n * @public\n */\nexport interface Stage {\n name: string;\n\n /** The status of the stage */\n status: FilterStatusType;\n\n /** Stage duration in milliseconds */\n duration: number;\n\n /** Sub stages within this stage */\n stages?: Array<Stage>;\n}\n\n/**\n * Generic Build type.\n *\n * A build has e.g. a build type (master/branch), a status and (possibly) sub stages.\n *\n * @public\n */\nexport interface Build {\n raw?: unknown;\n\n /** Build id */\n id: string;\n\n /** The reason this build was started */\n triggeredBy?: TriggerReason;\n\n /** The status of the build */\n status: FilterStatusType;\n\n /** Branch type */\n branchType: FilterBranchType;\n\n /** Time when the build started */\n requestedAt: Date;\n\n /** The overall duration of the build */\n duration: number;\n\n /** Top-level build stages */\n stages: Array<Stage>;\n}\n\n/**\n * Helper type which is a Build with a certain typed 'raw' field.\n *\n * This can be useful in an Api to use while mapping internal data structures\n * (raw) into generic builds.\n *\n * @public\n */\nexport type BuildWithRaw<T = any> = Build & {\n raw: T;\n};\n\n/**\n * Chart type.\n *\n * Values are:\n * * `duration`: shows an area chart of the duration over time\n * * `count`: shows a bar chart of the number of build per day\n *\n * @public\n */\nexport type ChartType = 'duration' | 'count';\n\n/**\n * Chart types.\n *\n * @public\n */\nexport type ChartTypes = Array<ChartType>;\n\n/**\n * Default settings for the fetching options and view options.\n *\n * These are all optional, but can be overridden from the Api to whatever makes\n * most sense for that implementation.\n *\n * @public\n */\nexport interface CicdDefaults {\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType>;\n filterType: FilterBranchType | 'all';\n\n /** Lower-case all stage names (to potentially merge stages with different cases) */\n lowercaseNames: boolean;\n /** Normalize the from-to date range in all charts */\n normalizeTimeRange: boolean;\n /** Default collapse the stages with a max-duration below this value */\n collapsedLimit: number;\n /** Default hide stages with a max-duration below this value */\n hideLimit: number;\n /** Chart types per status */\n chartTypes: Record<FilterStatusType, ChartTypes>;\n}\n\n/**\n * A configuration interface which the Api must implement.\n *\n * When the UI for the CI/CD Statistics is loaded, it begins with fetching the\n * configuration before anything else.\n *\n * All of these fields are optional though, and will fallback to hard-coded defaults.\n *\n * @public\n */\nexport interface CicdConfiguration {\n /**\n * This field can be used to override what statuses are available\n */\n availableStatuses: ReadonlyArray<FilterStatusType>;\n\n /**\n * When transposing the list of builds into a tree of stages, the stage names\n * will be transformed through this function.\n *\n * Override this for a custom implementation. The default will try to remove\n * parent names off of child names, if they are prepended by them.\n *\n * For example; if a stage has the name 'Install' and a child stage has the\n * name 'Install - Fetch dependencies', the child name will be replaced with\n * 'Fetch dependencies'.\n */\n formatStageName: (parentNames: Array<string>, stageName: string) => string;\n\n /**\n * Default options for the UI\n */\n defaults: Partial<CicdDefaults>;\n}\n\n/**\n * If the Api implements support for aborting the fetching of builds, throw an\n * AbortError of this type (or any other error with name === 'AbortError').\n *\n * @public\n */\nexport class AbortError extends Error {}\n\n/**\n * The result type for `fetchBuilds`.\n *\n * @public\n */\nexport interface CicdState {\n builds: Array<Build>;\n}\n\n/**\n * When fetching, if applicable, the Api can feedback progress back to the UI.\n *\n * Use the `updateProgress(completed, total, started?)` to signal that\n * `completed` builds out of a `total` has finished. Optionally use the\n * `started` to signal how many builds have been started in total (i.e. at least\n * the amount of `completed`).\n *\n * This can be called at any rate. Rate limiting (debouncing) is implemented in\n * the UI.\n *\n * Optionally this can signal multiple progresses in several steps\n *\n * @public\n */\nexport interface UpdateProgress {\n (completed: number, total: number, started?: number): void;\n (\n steps: Array<{\n title: string;\n completed: number;\n total: number;\n started?: number;\n }>,\n ): void;\n}\n\n/**\n * When reading configuration, the Api can return a custom settings depending on\n * the entity being viewed.\n *\n * @public\n */\nexport interface GetConfigurationOptions {\n entity: Entity;\n}\n\n/**\n * When fetching, the Api should fetch build information about the `entity` and\n * respect the `timeFrom`, `timeTo`, `filterStatus` and `filterType`.\n *\n * Optionally implement support for `updateProgress` and `abortSignal` if\n * preferred.\n *\n * When the UI re-fetches, it will abort any previous fetching, so polling\n * `abortSignal.aborted`, and possibly throwing an `AbortError`, can be useful.\n *\n * @public\n */\nexport interface FetchBuildsOptions {\n entity: Entity;\n updateProgress: UpdateProgress;\n abortSignal: AbortSignal;\n timeFrom: Date;\n timeTo: Date;\n filterStatus: Array<FilterStatusType | 'all'>;\n filterType: FilterBranchType | 'all';\n}\n\n/**\n * The interface which is mapped to the `cicdStatisticsApiRef` which is used by\n * the UI.\n *\n * @public\n */\nexport interface CicdStatisticsApi {\n getConfiguration(\n options: GetConfigurationOptions,\n ): Promise<Partial<CicdConfiguration>>;\n fetchBuilds(options: FetchBuildsOptions): Promise<CicdState>;\n}\n"],"names":[],"mappings":"AAwCO,MAAM,WAAA,GAAuC;AAAA,EAClD,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AA6BO,MAAM,cAAA,GAAuC;AAAA,EAClD,KAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAyJO,MAAM,mBAAmB,KAAA,CAAM;AAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"colors.esm.js","sources":["../../src/charts/colors.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType, TriggerReason } from '../apis/types';\n\nexport const statusColorMap: Record<FilterStatusType, string> = {\n unknown: '#3d01a4',\n enqueued: '#7ad1b9',\n scheduled: '#0391ce',\n running: '#f3f318',\n aborted: '#8600af',\n succeeded: '#66b032',\n failed: '#fe2712',\n stalled: '#fb9904',\n expired: '#a7194b',\n};\n\nexport const triggerColorMap: Record<TriggerReason, string> = {\n scm: '#0391ce',\n manual: '#a7194b',\n internal: '#82ca9d',\n other: '#f3f318',\n};\n\nexport const fireColors: Array<[percent: string, color: string]> = [\n ['5%', '#e19678'],\n ['30%', '#dfe178'],\n ['50%', '#82ca9d'],\n ['95%', '#82ca9d'],\n];\n\nexport const colorStroke = '#c0c0c0';\nexport const colorStrokeAvg = '#788ee1';\n"],"names":[],"mappings":"AAkBO,MAAM,cAAmD,GAAA;AAAA,EAC9D,OAAS,EAAA,SAAA;AAAA,EACT,QAAU,EAAA,SAAA;AAAA,EACV,SAAW,EAAA,SAAA;AAAA,EACX,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,SAAW,EAAA,SAAA;AAAA,EACX,MAAQ,EAAA,SAAA;AAAA,EACR,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA;AACX;AAEO,MAAM,eAAiD,GAAA;AAAA,EAC5D,GAAK,EAAA,SAAA;AAAA,EACL,MAAQ,EAAA,SAAA;AAAA,EACR,QAAU,EAAA,SAAA;AAAA,EACV,KAAO,EAAA;AACT;AAEO,MAAM,UAAsD,GAAA;AAAA,EACjE,CAAC,MAAM,SAAS,CAAA;AAAA,EAChB,CAAC,OAAO,SAAS,CAAA;AAAA,EACjB,CAAC,OAAO,SAAS,CAAA;AAAA,EACjB,CAAC,OAAO,SAAS;AACnB;AAEO,MAAM,WAAc,GAAA;AACpB,MAAM,cAAiB,GAAA;;;;"}
1
+ {"version":3,"file":"colors.esm.js","sources":["../../src/charts/colors.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType, TriggerReason } from '../apis/types';\n\nexport const statusColorMap: Record<FilterStatusType, string> = {\n unknown: '#3d01a4',\n enqueued: '#7ad1b9',\n scheduled: '#0391ce',\n running: '#f3f318',\n aborted: '#8600af',\n succeeded: '#66b032',\n failed: '#fe2712',\n stalled: '#fb9904',\n expired: '#a7194b',\n};\n\nexport const triggerColorMap: Record<TriggerReason, string> = {\n scm: '#0391ce',\n manual: '#a7194b',\n internal: '#82ca9d',\n other: '#f3f318',\n};\n\nexport const fireColors: Array<[percent: string, color: string]> = [\n ['5%', '#e19678'],\n ['30%', '#dfe178'],\n ['50%', '#82ca9d'],\n ['95%', '#82ca9d'],\n];\n\nexport const colorStroke = '#c0c0c0';\nexport const colorStrokeAvg = '#788ee1';\n"],"names":[],"mappings":"AAkBO,MAAM,cAAA,GAAmD;AAAA,EAC9D,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,SAAA,EAAW,SAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,SAAA,EAAW,SAAA;AAAA,EACX,MAAA,EAAQ,SAAA;AAAA,EACR,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS;AACX;AAEO,MAAM,eAAA,GAAiD;AAAA,EAC5D,GAAA,EAAK,SAAA;AAAA,EACL,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,SAAA;AAAA,EACV,KAAA,EAAO;AACT;AAEO,MAAM,UAAA,GAAsD;AAAA,EACjE,CAAC,MAAM,SAAS,CAAA;AAAA,EAChB,CAAC,OAAO,SAAS,CAAA;AAAA,EACjB,CAAC,OAAO,SAAS,CAAA;AAAA,EACjB,CAAC,OAAO,SAAS;AACnB;AAEO,MAAM,WAAA,GAAc;AACpB,MAAM,cAAA,GAAiB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.esm.js","sources":["../../../src/charts/logic/analysis.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType } from '../../apis/types';\nimport { ChartableStageAnalysis, ChartableStageDatapoints } from '../types';\n\nexport function getAnalysis(\n values: Array<ChartableStageDatapoints>,\n status: FilterStatusType,\n): ChartableStageAnalysis {\n const analysis: ChartableStageAnalysis = {\n max: 0,\n min: 0,\n avg: 0,\n med: 0,\n };\n\n const definedValues = values\n .filter(value => typeof value[status] !== 'undefined')\n .map(value => value[status]!)\n .sort((a, b) => a - b);\n\n analysis.max = definedValues[definedValues.length - 1] ?? 0;\n\n analysis.min = definedValues[0] ?? 0;\n\n analysis.avg =\n definedValues.length === 0\n ? 0\n : definedValues.reduce((prev, cur) => prev + cur, 0) / values.length;\n\n analysis.med = definedValues[Math.ceil(definedValues.length / 2)] ?? 0;\n\n return analysis;\n}\n\nexport function makeCombinedAnalysis(\n analysis: Record<FilterStatusType, ChartableStageAnalysis>,\n allDurations: Array<number>,\n): ChartableStageAnalysis {\n if (analysis.succeeded) {\n // If succeeded is a viewed status, it's probably what's expected to see\n // overall. Otherwise combine all other.\n return analysis.succeeded;\n }\n\n const analysisValues = Object.values(analysis);\n\n const max = analysisValues.reduce((prev, cur) => Math.max(prev, cur.max), 0);\n const min = analysisValues.reduce(\n (prev, cur) => Math.min(prev, cur.min),\n max,\n );\n const avg = !allDurations.length\n ? 0\n : allDurations.reduce((prev, cur) => prev + cur, 0) / allDurations.length;\n allDurations.sort((a, b) => a - b);\n const med = allDurations[Math.ceil(allDurations.length / 2)] ?? 0;\n\n return {\n max,\n min,\n avg,\n med,\n };\n}\n"],"names":[],"mappings":"AAmBgB,SAAA,WAAA,CACd,QACA,MACwB,EAAA;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G,CAAC,CAAA;AAC3E,EAAA,MAAM,MAAM,cAAe,CAAA,MAAA;AAAA,IACzB,CAAC,IAAM,EAAA,GAAA,KAAQ,KAAK,GAAI,CAAA,IAAA,EAAM,IAAI,GAAG,CAAA;AAAA,IACrC;AAAA,GACF;AACA,EAAA,MAAM,GAAM,GAAA,CAAC,YAAa,CAAA,MAAA,GACtB,IACA,YAAa,CAAA,MAAA,CAAO,CAAC,IAAA,EAAM,GAAQ,KAAA,IAAA,GAAO,GAAK,EAAA,CAAC,IAAI,YAAa,CAAA,MAAA;AACrE,EAAA,YAAA,CAAa,IAAK,CAAA,CAAC,CAAG,EAAA,CAAA,KAAM,IAAI,CAAC,CAAA;AACjC,EAAM,MAAA,GAAA,GAAM,aAAa,IAAK,CAAA,IAAA,CAAK,aAAa,MAAS,GAAA,CAAC,CAAC,CAAK,IAAA,CAAA;AAEhE,EAAO,OAAA;AAAA,IACL,GAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"analysis.esm.js","sources":["../../../src/charts/logic/analysis.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType } from '../../apis/types';\nimport { ChartableStageAnalysis, ChartableStageDatapoints } from '../types';\n\nexport function getAnalysis(\n values: Array<ChartableStageDatapoints>,\n status: FilterStatusType,\n): ChartableStageAnalysis {\n const analysis: ChartableStageAnalysis = {\n max: 0,\n min: 0,\n avg: 0,\n med: 0,\n };\n\n const definedValues = values\n .filter(value => typeof value[status] !== 'undefined')\n .map(value => value[status]!)\n .sort((a, b) => a - b);\n\n analysis.max = definedValues[definedValues.length - 1] ?? 0;\n\n analysis.min = definedValues[0] ?? 0;\n\n analysis.avg =\n definedValues.length === 0\n ? 0\n : definedValues.reduce((prev, cur) => prev + cur, 0) / values.length;\n\n analysis.med = definedValues[Math.ceil(definedValues.length / 2)] ?? 0;\n\n return analysis;\n}\n\nexport function makeCombinedAnalysis(\n analysis: Record<FilterStatusType, ChartableStageAnalysis>,\n allDurations: Array<number>,\n): ChartableStageAnalysis {\n if (analysis.succeeded) {\n // If succeeded is a viewed status, it's probably what's expected to see\n // overall. Otherwise combine all other.\n return analysis.succeeded;\n }\n\n const analysisValues = Object.values(analysis);\n\n const max = analysisValues.reduce((prev, cur) => Math.max(prev, cur.max), 0);\n const min = analysisValues.reduce(\n (prev, cur) => Math.min(prev, cur.min),\n max,\n );\n const avg = !allDurations.length\n ? 0\n : allDurations.reduce((prev, cur) => prev + cur, 0) / allDurations.length;\n allDurations.sort((a, b) => a - b);\n const med = allDurations[Math.ceil(allDurations.length / 2)] ?? 0;\n\n return {\n max,\n min,\n avg,\n med,\n };\n}\n"],"names":[],"mappings":"AAmBO,SAAS,WAAA,CACd,QACA,MAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAmC;AAAA,IACvC,GAAA,EAAK,CAAA;AAAA,IACL,GAAA,EAAK,CAAA;AAAA,IACL,GAAA,EAAK,CAAA;AAAA,IACL,GAAA,EAAK;AAAA,GACP;AAEA,EAAA,MAAM,aAAA,GAAgB,OACnB,MAAA,CAAO,CAAA,KAAA,KAAS,OAAO,KAAA,CAAM,MAAM,MAAM,WAAW,CAAA,CACpD,IAAI,CAAA,KAAA,KAAS,KAAA,CAAM,MAAM,CAAE,CAAA,CAC3B,KAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,GAAI,CAAC,CAAA;AAEvB,EAAA,QAAA,CAAS,GAAA,GAAM,aAAA,CAAc,aAAA,CAAc,MAAA,GAAS,CA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Aa,IAAA,CAAK,IAAA,CAAK,aAAa,MAAA,GAAS,CAAC,CAAC,CAAA,IAAK,CAAA;AAEhE,EAAA,OAAO;AAAA,IACL,GAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { map } from 'already';
2
- import { sortStatuses, makeStage, getOrSetStage } from './utils.esm.js';
2
+ import { makeStage, getOrSetStage, sortStatuses } from './utils.esm.js';
3
3
  import { finalizeStage } from './finalize-stage.esm.js';
4
4
  import { dailySummary } from './daily-summary.esm.js';
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"conversions.esm.js","sources":["../../../src/charts/logic/conversions.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { map } from 'already';\n\nimport { Build, Stage, FilterStatusType } from '../../apis/types';\nimport { ChartableStage, ChartableStagesAnalysis } from '../types';\nimport { getOrSetStage, makeStage, sortStatuses } from './utils';\nimport { finalizeStage } from './finalize-stage';\nimport { dailySummary } from './daily-summary';\n\nexport interface ChartableStagesOptions {\n normalizeTimeRange: boolean;\n}\n\n/**\n * Converts a list of builds, each with a tree of stages (and durations) into a\n * merged tree of stages, and calculates {avg, min, max} of each stage.\n */\nexport async function buildsToChartableStages(\n builds: Array<Build>,\n options: ChartableStagesOptions,\n): Promise<ChartableStagesAnalysis> {\n const { normalizeTimeRange } = options;\n\n const total: ChartableStage = makeStage('Total');\n\n const recurseDown = (\n stageMap: Map<string, ChartableStage>,\n stage: Stage,\n __epoch: number,\n ) => {\n const { name, status, duration } = stage;\n\n const subChartableStage = getOrSetStage(stageMap, name);\n\n subChartableStage.statusSet.add(status);\n subChartableStage.values.push({\n __epoch,\n [status]: duration,\n [`${status} avg`]: duration,\n });\n\n stage.stages?.forEach(subStage => {\n recurseDown(subChartableStage.stages, subStage, __epoch);\n });\n };\n\n const stages = new Map<string, ChartableStage>();\n\n await map(builds, { chunk: 'idle' }, build => {\n const { duration, requestedAt, status } = build;\n const __epoch = requestedAt.getTime();\n\n total.statusSet.add(status);\n total.values.push({\n __epoch,\n [status]: duration,\n [`${status} avg`]: duration,\n });\n\n build.stages?.forEach(subStage => {\n recurseDown(stages, subStage, __epoch);\n });\n });\n\n const allEpochs = normalizeTimeRange\n ? builds.map(build => build.requestedAt.getTime())\n : [];\n\n // Recurse down again and calculate averages\n await map([...stages.values()], { chunk: 'idle' }, stage =>\n finalizeStage(stage, { allEpochs, averageWidth: 10 }),\n );\n finalizeStage(total, { allEpochs, averageWidth: 10 });\n\n const daily = dailySummary(builds);\n\n const statuses = findStatuses(total, [...stages.values()]);\n\n return { daily, total, stages, statuses };\n}\n\nfunction findStatuses(\n total: ChartableStage,\n stages: Array<ChartableStage>,\n): Array<string> {\n const statuses = new Set<string>();\n\n const addStatuses = (set: Set<FilterStatusType>) => {\n set.forEach(status => {\n statuses.add(status);\n });\n };\n\n addStatuses(total.statusSet);\n\n const recurse = (subStages: Array<ChartableStage>) => {\n subStages.forEach(stage => {\n addStatuses(stage.statusSet);\n recurse([...stage.stages.values()]);\n });\n };\n recurse(stages);\n\n return sortStatuses([...statuses]);\n}\n"],"names":[],"mappings":";;;;;AAgCsB,eAAA,uBAAA,CACpB,QACA,OACkC,EAAA;AAClC,EAAM,MAAA,EAAE,oBAAuB,GAAA,OAAA;AAE/B,EAAM,MAAA,KAAA,GAAwB,UAAU,OAAO,CAAA;AAE/C,EAAA,MAAM,WAAc,GAAA,CAClB,QACA,EAAA,KAAA,EACA,OACG,KAAA;AACH,IAAA,MAAM,EAAE,IAA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{"version":3,"file":"conversions.esm.js","sources":["../../../src/charts/logic/conversions.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { map } from 'already';\n\nimport { Build, Stage, FilterStatusType } from '../../apis/types';\nimport { ChartableStage, ChartableStagesAnalysis } from '../types';\nimport { getOrSetStage, makeStage, sortStatuses } from './utils';\nimport { finalizeStage } from './finalize-stage';\nimport { dailySummary } from './daily-summary';\n\nexport interface ChartableStagesOptions {\n normalizeTimeRange: boolean;\n}\n\n/**\n * Converts a list of builds, each with a tree of stages (and durations) into a\n * merged tree of stages, and calculates {avg, min, max} of each stage.\n */\nexport async function buildsToChartableStages(\n builds: Array<Build>,\n options: ChartableStagesOptions,\n): Promise<ChartableStagesAnalysis> {\n const { normalizeTimeRange } = options;\n\n const total: ChartableStage = makeStage('Total');\n\n const recurseDown = (\n stageMap: Map<string, ChartableStage>,\n stage: Stage,\n __epoch: number,\n ) => {\n const { name, status, duration } = stage;\n\n const subChartableStage = getOrSetStage(stageMap, name);\n\n subChartableStage.statusSet.add(status);\n subChartableStage.values.push({\n __epoch,\n [status]: duration,\n [`${status} avg`]: duration,\n });\n\n stage.stages?.forEach(subStage => {\n recurseDown(subChartableStage.stages, subStage, __epoch);\n });\n };\n\n const stages = new Map<string, ChartableStage>();\n\n await map(builds, { chunk: 'idle' }, build => {\n const { duration, requestedAt, status } = build;\n const __epoch = requestedAt.getTime();\n\n total.statusSet.add(status);\n total.values.push({\n __epoch,\n [status]: duration,\n [`${status} avg`]: duration,\n });\n\n build.stages?.forEach(subStage => {\n recurseDown(stages, subStage, __epoch);\n });\n });\n\n const allEpochs = normalizeTimeRange\n ? builds.map(build => build.requestedAt.getTime())\n : [];\n\n // Recurse down again and calculate averages\n await map([...stages.values()], { chunk: 'idle' }, stage =>\n finalizeStage(stage, { allEpochs, averageWidth: 10 }),\n );\n finalizeStage(total, { allEpochs, averageWidth: 10 });\n\n const daily = dailySummary(builds);\n\n const statuses = findStatuses(total, [...stages.values()]);\n\n return { daily, total, stages, statuses };\n}\n\nfunction findStatuses(\n total: ChartableStage,\n stages: Array<ChartableStage>,\n): Array<string> {\n const statuses = new Set<string>();\n\n const addStatuses = (set: Set<FilterStatusType>) => {\n set.forEach(status => {\n statuses.add(status);\n });\n };\n\n addStatuses(total.statusSet);\n\n const recurse = (subStages: Array<ChartableStage>) => {\n subStages.forEach(stage => {\n addStatuses(stage.statusSet);\n recurse([...stage.stages.values()]);\n });\n };\n recurse(stages);\n\n return sortStatuses([...statuses]);\n}\n"],"names":[],"mappings":";;;;;AAgCA,eAAsB,uBAAA,CACpB,QACA,OAAA,EACkC;AAClC,EAAA,MAAM,EAAE,oBAAmB,GAAI,OAAA;AAE/B,EAAA,MAAM,KAAA,GAAwB,UAAU,OAAO,CAAA;AAE/C,EAAA,MAAM,WAAA,GAAc,CAClB,QAAA,EACA,KAAA,EACA,OAAA,KACG;AACH,IAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAS,GAAI,KAAA;AAEnC,IAAA,MAAM,iBAAA,GAAoB,aAAA,CAAc,QAAA,EAAU,IAAI,CAAA;AAEtD,IAAA,iBAAA,CAAkB,SAAA,CAAU,IAAI,MAAM,CAAA;AACtC,IAAA,iBAAA,CAAkB,OAAO,IAAA,CAAK;AAAA,MAC5B,OAAA;AAAA,MACA,CAAC,MAAM,GAAG,QAAA;AAAA,MACV,CAAC,CAAA,EAAG,MAAM,CAAA,IAAA,CAAM,GAAG;AAAA,KACpB,CAAA;AAED,IAAA,KAAA,CAAM,MAAA,EAAQ,QAAQ,CAAA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AAM,CAAA;AAEjC,EAAA,MAAM,QAAA,GAAW,aAAa,KAAA,EAAO,CAAC,GAAG,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAEzD,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAS;AAC1C;AAEA,SAAS,YAAA,CACP,OACA,MAAA,EACe;AACf,EAAA,MAAM,QAAA,uBAAe,GAAA,EAAY;AAEjC,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,KAA+B;AAClD,IAAA,GAAA,CAAI,QAAQ,CAAA,MAAA,KAAU;AACpB,MAAA,QAAA,CAAS,IAAI,MAAM,CAAA;AAAA,IACrB,CAAC,CAAA;AAAA,EACH,CAAA;AAEA,EAAA,WAAA,CAAY,MAAM,SAAS,CAAA;AAE3B,EAAA,MAAM,OAAA,GAAU,CAAC,SAAA,KAAqC;AACpD,IAAA,SAAA,CAAU,QAAQ,CAAA,KAAA,KAAS;AACzB,MAAA,WAAA,CAAY,MAAM,SAAS,CAAA;AAC3B,MAAA,OAAA,CAAQ,CAAC,GAAG,KAAA,CAAM,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAAA,IACpC,CAAC,CAAA;AAAA,EACH,CAAA;AACA,EAAA,OAAA,CAAQ,MAAM,CAAA;AAEd,EAAA,OAAO,YAAA,CAAa,CAAC,GAAG,QAAQ,CAAC,CAAA;AACnC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"count-builds-per-day.esm.js","sources":["../../../src/charts/logic/count-builds-per-day.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { groupBy } from 'lodash';\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { Countify, ChartableStageDatapoints } from '../types';\nimport { startOfDay } from './utils';\n\nexport function countBuildsPerDay(\n values: ReadonlyArray<ChartableStageDatapoints>,\n) {\n const days = groupBy(values, value => startOfDay(value.__epoch));\n Object.entries(days).forEach(([_startOfDay, valuesThisDay]) => {\n const counts = Object.fromEntries(\n statusTypes\n .map(\n type =>\n [\n type,\n valuesThisDay.filter(value => value[type] !== undefined).length,\n ] as const,\n )\n .filter(([_type, count]) => count > 0)\n .map(([type, count]): [Countify<FilterStatusType>, number] => [\n `${type} count`,\n count,\n ]),\n );\n\n // Assign the count for this day to the first value this day\n Object.assign(valuesThisDay[0], counts);\n });\n}\n"],"names":[],"mappings":";;;;AAsBO,SAAS,kBACd,MACA,EAAA;AACA,EAAA,MAAM,OAAO,OAAQ,CAAA,MAAA,EAAQ,WAAS,UAAW,CAAA,KAAA,CAAM,OAAO,CAAC,CAAA;AAC/D,EAAO,MAAA,CAAA,OAAA,CAAQ,IAAI,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,WAAA,EAAa,aAAa,CAAM,KAAA;AAC7D,IAAA,MAAM,SAAS,MAAO,CAAA,WAAA;AAAA,MACpB,WACG,CAAA,GAAA;AAAA,QACC,CACE,IAAA,KAAA;AAAA,UACE,IAAA;AAAA,UACA,cAAc,MAAO,CAAA,CAAA,KAAA,KAAS,MAAM,IAAI,CAAA,KAAM,MAAS,CAAE,CAAA;AAAA;AAC3D,OAEH,CAAA,MAAA,CAAO,CAAC,CAAC,OAAO,KAAK,CAAA,KAAM,KAAQ,GAAA,CAAC,EACpC,GAAI,CAAA,CAAC,CAAC,IAAA,EAAM,KAAK,CAA4C,KAAA;AAAA,QAC5D,GAAG,IAAI,CAAA,MAAA,CAAA;AAAA,QACP;AAAA,OACD;AAAA,KACL;AAGA,IAAA,MAAA,CAAO,MAAO,CAAA,aAAA,CAAc,CAAC,CAAA,EAAG,MAAM,CAAA;AAAA,GACvC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"count-builds-per-day.esm.js","sources":["../../../src/charts/logic/count-builds-per-day.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { groupBy } from 'lodash';\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { Countify, ChartableStageDatapoints } from '../types';\nimport { startOfDay } from './utils';\n\nexport function countBuildsPerDay(\n values: ReadonlyArray<ChartableStageDatapoints>,\n) {\n const days = groupBy(values, value => startOfDay(value.__epoch));\n Object.entries(days).forEach(([_startOfDay, valuesThisDay]) => {\n const counts = Object.fromEntries(\n statusTypes\n .map(\n type =>\n [\n type,\n valuesThisDay.filter(value => value[type] !== undefined).length,\n ] as const,\n )\n .filter(([_type, count]) => count > 0)\n .map(([type, count]): [Countify<FilterStatusType>, number] => [\n `${type} count`,\n count,\n ]),\n );\n\n // Assign the count for this day to the first value this day\n Object.assign(valuesThisDay[0], counts);\n });\n}\n"],"names":[],"mappings":";;;;AAsBO,SAAS,kBACd,MAAA,EACA;AACA,EAAA,MAAM,OAAO,OAAA,CAAQ,MAAA,EAAQ,WAAS,UAAA,CAAW,KAAA,CAAM,OAAO,CAAC,CAAA;AAC/D,EAAA,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,WAAA,EAAa,aAAa,CAAA,KAAM;AAC7D,IAAA,MAAM,SAAS,MAAA,CAAO,WAAA;AAAA,MACpB,WAAA,CACG,GAAA;AAAA,QACC,CAAA,IAAA,KACE;AAAA,UACE,IAAA;AAAA,UACA,cAAc,MAAA,CAAO,CAAA,KAAA,KAAS,MAAM,IAAI,CAAA,KAAM,MAAS,CAAA,CAAE;AAAA;AAC3D,OACJ,CACC,MAAA,CAAO,CAAC,CAAC,OAAO,KAAK,CAAA,KAAM,KAAA,GAAQ,CAAC,EACpC,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,KAAK,CAAA,KAA4C;AAAA,QAC5D,GAAG,IAAI,CAAA,MAAA,CAAA;AAAA,QACP;AAAA,OACD;AAAA,KACL;AAGA,IAAA,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,CAAC,CAAA,EAAG,MAAM,CAAA;AAAA,EACxC,CAAC,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"daily-summary.esm.js","sources":["../../../src/charts/logic/daily-summary.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { groupBy, countBy } from 'lodash';\n\nimport { Build } from '../../apis/types';\nimport {\n Epoch,\n TriggerReasonsDatapoint,\n StatusesDatapoint,\n ChartableDaily,\n} from '../types';\nimport { sortStatuses, sortTriggerReasons, startOfDay } from './utils';\n\nexport function dailySummary(builds: ReadonlyArray<Build>): ChartableDaily {\n const triggersDaily = countTriggersPerDay(builds);\n const statusesDaily = countStatusesPerDay(builds);\n\n const { triggerReasons } = triggersDaily;\n const { statuses } = statusesDaily;\n\n const reasonMap = new Map(\n triggersDaily.values.map(value => [value.__epoch, value]),\n );\n const statusMap = new Map(\n statusesDaily.values.map(value => [value.__epoch, value]),\n );\n\n const days = Object.keys(\n groupBy(builds, value => startOfDay(value.requestedAt)),\n )\n .map(epoch => parseInt(epoch, 10))\n .sort();\n\n return {\n values: days.map(epoch => ({\n __epoch: epoch,\n ...reasonMap.get(epoch),\n ...statusMap.get(epoch),\n })),\n triggerReasons,\n statuses,\n };\n}\n\nfunction countTriggersPerDay(builds: ReadonlyArray<Build>) {\n const days = groupBy(builds, value => startOfDay(value.requestedAt));\n\n const triggerReasons = sortTriggerReasons([\n ...new Set(\n builds\n .map(({ triggeredBy }) => triggeredBy)\n .filter((v): v is NonNullable<typeof v> => !!v),\n ),\n ]);\n\n const values = Object.entries(days).map(([epoch, buildsThisDay]) => {\n const datapoint = Object.fromEntries(\n triggerReasons\n .map(\n reason =>\n [\n reason,\n buildsThisDay.filter(build => build.triggeredBy === reason)\n .length,\n ] as const,\n )\n .filter(([_type, count]) => count > 0),\n ) as Omit<TriggerReasonsDatapoint, '__epoch'>;\n\n // Assign the count for this day to the first value this day\n const value: Epoch & TriggerReasonsDatapoint = Object.assign(datapoint, {\n __epoch: parseInt(epoch, 10),\n });\n\n return value;\n });\n\n return { triggerReasons, values };\n}\n\nfunction countStatusesPerDay(builds: ReadonlyArray<Build>) {\n const days = groupBy(builds, value => startOfDay(value.requestedAt));\n\n const foundStatuses = new Set<string>();\n\n const values = Object.entries(days).map(([epoch, buildsThisDay]) => {\n const byStatus = countBy(buildsThisDay, 'status');\n\n const value: Epoch & StatusesDatapoint = {\n __epoch: parseInt(epoch, 10),\n ...byStatus,\n };\n\n Object.keys(byStatus).forEach(status => {\n foundStatuses.add(status);\n });\n\n return value;\n });\n\n return {\n statuses: sortStatuses([...foundStatuses]),\n values,\n };\n}\n"],"names":[],"mappings":";;;AA2BO,SAAS,aAAa,MAA8C,EAAA;AACzE,EAAM,MAAA,aAAA,GAAgB,oBAAoB,MAAM,CAAA;AAChD,EAAM,MAAA,aAAA,GAAgB,oBAAoB,MAAM,CAAA;AAEhD,EAAM,MAAA,EA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AAA,CAAc,IAAI,MAAM,CAAA;AAAA,KACzB,CAAA;AAED,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAO,OAAA;AAAA,IACL,QAAU,EAAA,YAAA,CAAa,CAAC,GAAG,aAAa,CAAC,CAAA;AAAA,IACzC;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"daily-summary.esm.js","sources":["../../../src/charts/logic/daily-summary.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { groupBy, countBy } from 'lodash';\n\nimport { Build } from '../../apis/types';\nimport {\n Epoch,\n TriggerReasonsDatapoint,\n StatusesDatapoint,\n ChartableDaily,\n} from '../types';\nimport { sortStatuses, sortTriggerReasons, startOfDay } from './utils';\n\nexport function dailySummary(builds: ReadonlyArray<Build>): ChartableDaily {\n const triggersDaily = countTriggersPerDay(builds);\n const statusesDaily = countStatusesPerDay(builds);\n\n const { triggerReasons } = triggersDaily;\n const { statuses } = statusesDaily;\n\n const reasonMap = new Map(\n triggersDaily.values.map(value => [value.__epoch, value]),\n );\n const statusMap = new Map(\n statusesDaily.values.map(value => [value.__epoch, value]),\n );\n\n const days = Object.keys(\n groupBy(builds, value => startOfDay(value.requestedAt)),\n )\n .map(epoch => parseInt(epoch, 10))\n .sort();\n\n return {\n values: days.map(epoch => ({\n __epoch: epoch,\n ...reasonMap.get(epoch),\n ...statusMap.get(epoch),\n })),\n triggerReasons,\n statuses,\n };\n}\n\nfunction countTriggersPerDay(builds: ReadonlyArray<Build>) {\n const days = groupBy(builds, value => startOfDay(value.requestedAt));\n\n const triggerReasons = sortTriggerReasons([\n ...new Set(\n builds\n .map(({ triggeredBy }) => triggeredBy)\n .filter((v): v is NonNullable<typeof v> => !!v),\n ),\n ]);\n\n const values = Object.entries(days).map(([epoch, buildsThisDay]) => {\n const datapoint = Object.fromEntries(\n triggerReasons\n .map(\n reason =>\n [\n reason,\n buildsThisDay.filter(build => build.triggeredBy === reason)\n .length,\n ] as const,\n )\n .filter(([_type, count]) => count > 0),\n ) as Omit<TriggerReasonsDatapoint, '__epoch'>;\n\n // Assign the count for this day to the first value this day\n const value: Epoch & TriggerReasonsDatapoint = Object.assign(datapoint, {\n __epoch: parseInt(epoch, 10),\n });\n\n return value;\n });\n\n return { triggerReasons, values };\n}\n\nfunction countStatusesPerDay(builds: ReadonlyArray<Build>) {\n const days = groupBy(builds, value => startOfDay(value.requestedAt));\n\n const foundStatuses = new Set<string>();\n\n const values = Object.entries(days).map(([epoch, buildsThisDay]) => {\n const byStatus = countBy(buildsThisDay, 'status');\n\n const value: Epoch & StatusesDatapoint = {\n __epoch: parseInt(epoch, 10),\n ...byStatus,\n };\n\n Object.keys(byStatus).forEach(status => {\n foundStatuses.add(status);\n });\n\n return value;\n });\n\n return {\n statuses: sortStatuses([...foundStatuses]),\n values,\n };\n}\n"],"names":[],"mappings":";;;AA2BO,SAAS,aAAa,MAAA,EAA8C;AACzE,EAAA,MAAM,aAAA,GAAgB,oBAAoB,MAAM,CAAA;AAChD,EAAA,MAAM,aAAA,GAAgB,oBAAoB,MAAM,CAAA;AAEhD,EAAA,MAAM,EAAE,gBAAe,GAAI,aAAA;AAC3B,EAAA,MAAM,EAAE,UAAS,GAAI,aAAA;AAErB,EAAA,MAAM,YAAY,IAAI,GAAA;AAAA,IACpB,aAAA,CAAc,OAAO,GAAA,CAAI,CAAA,KAAA,KAAS,CAAC,KAAA,CAAM,OAAA,EAAS,KAAK,CAAC;AAAA,GAC1D;AACA,EAAA,MAAM,YAAY,IAAI,GAAA;AAAA,IACpB,aAAA,CAAc,OAA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logic/finalize-stage.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { Averagify, ChartableStage } from '../types';\nimport { countBuildsPerDay } from './count-builds-per-day';\nimport { getAnalysis, makeCombinedAnalysis } from './analysis';\nimport { average } from './utils';\n\ninterface FinalizeStageOptions {\n averageWidth: number;\n allEpochs: Array<number>;\n}\n\n/**\n * Calculate:\n * * {avg, min, max}\n * * count per day\n * of a stage and its sub stages, recursively.\n *\n * This is calculated per status (successful, failed, etc).\n */\nexport function finalizeStage(\n stage: ChartableStage,\n options: FinalizeStageOptions,\n) {\n const { averageWidth, allEpochs } = options;\n const { values, analysis, combinedAnalysis } = stage;\n\n if (allEpochs.length > 0) {\n const valueEpochs = new Set(values.map(value => value.__epoch));\n\n allEpochs.forEach(epoch => {\n if (!valueEpochs.has(epoch)) {\n values.push({ __epoch: epoch });\n }\n });\n }\n\n values.sort((a, b) => a.__epoch - b.__epoch);\n\n countBuildsPerDay(values);\n\n const allDurations: Array<number> = [];\n\n statusTypes.forEach(status => {\n analysis[status] = getAnalysis(values, status);\n\n const durationsIndexes = values\n .map(value => value[status])\n .map((duration, index) => ({ index, duration }))\n .filter(({ duration }) => typeof duration !== 'undefined')\n .map(({ index }) => index);\n const durationsDense = values\n .map(value => value[status])\n .filter(\n (duration): duration is number => typeof duration !== 'undefined',\n );\n\n durationsDense.forEach(dur => allDurations.push(dur));\n\n const averages = durationsDense.map((_, i) =>\n average(\n durationsDense.slice(\n Math.max(i - averageWidth, 0),\n Math.min(i + averageWidth, durationsDense.length),\n ),\n ),\n );\n\n averages.forEach((avg, index) => {\n const key: Averagify<FilterStatusType> = `${status} avg`;\n values[durationsIndexes[index]][key] = avg;\n });\n });\n\n Object.assign(combinedAnalysis, makeCombinedAnalysis(analysis, allDurations));\n\n stage.stages.forEach(subStage => finalizeStage(subStage, options));\n}\n"],"names":[],"mappings":";;;;;AAmCgB,SAAA,aAAA,CACd,OACA,OACA,EAAA;AACA,EAAM,MAAA,EAAE,YAAc,EAAA,SAAA,EAAc,GAAA,OAAA;AACpC,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAU,EAAA,gBAAA,EAAqB,GAAA,KAAA;AAE/C,EAAI,IAAA,SAAA,CAAU,SAAS,CAAG,EAAA;AACxB,IAAM,MAAA,WAAA,GAAc,IAAI,GAAI,CAAA,MAAA,CAAO,IAAI,CAAS,KAAA,KAAA,KAAA,CAAM,OAAO,CAAC,CAAA;AAE9D,IAAA,SAAA,CAAU,QAAQ,CAAS,KAAA,KAAA;AACzB,MAAA,IAAI,CAAC,WAAA,CAAY,GAAI,CAAA,KAAK,CAAG,EAAA;AAC3B,QAAA,MAAA,CAAO,IAAK,CAAA,EAAE,OAAS,EAAA,KAAA,EAAO,CAAA;AAAA;AAChC,KACD,CAAA;AAAA;AAGH,EAAA,MAAA,CAAO,KAAK,CAAC,CAAA,EAAG,MAAM,CAAE,CAAA,OAAA,GAAU,EAAE,OAAO,CAAA;AAE3C,EAAA,iBAAA,CAAkB,MAAM,CAAA;AAExB,EAAA,MAAM,eAA8B,EAAC;AAErC,EAAA,WAAA,CAAY,QAAQ,CAAU,MAAA,KAAA;AAC5B,IAAA,QAAA,CAAS,MAAM,CAAA,GAAI,WAAY,CAAA,MAAA,EAAQ,MAAM,CAAA;AAE7C,IAAA,MAAM,gBAAmB,GAAA,MAAA,CACtB,GAAI,CAAA,CAAA,KAAA,KAAS,KAAM,CAAA,MAAM,CAAC,CAAA,CAC1B,GAAI,CAAA,CAAC,QAAU,EAAA,KAAA,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stage.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { Averagify, ChartableStage } from '../types';\nimport { countBuildsPerDay } from './count-builds-per-day';\nimport { getAnalysis, makeCombinedAnalysis } from './analysis';\nimport { average } from './utils';\n\ninterface FinalizeStageOptions {\n averageWidth: number;\n allEpochs: Array<number>;\n}\n\n/**\n * Calculate:\n * * {avg, min, max}\n * * count per day\n * of a stage and its sub stages, recursively.\n *\n * This is calculated per status (successful, failed, etc).\n */\nexport function finalizeStage(\n stage: ChartableStage,\n options: FinalizeStageOptions,\n) {\n const { averageWidth, allEpochs } = options;\n const { values, analysis, combinedAnalysis } = stage;\n\n if (allEpochs.length > 0) {\n const valueEpochs = new Set(values.map(value => value.__epoch));\n\n allEpochs.forEach(epoch => {\n if (!valueEpochs.has(epoch)) {\n values.push({ __epoch: epoch });\n }\n });\n }\n\n values.sort((a, b) => a.__epoch - b.__epoch);\n\n countBuildsPerDay(values);\n\n const allDurations: Array<number> = [];\n\n statusTypes.forEach(status => {\n analysis[status] = getAnalysis(values, status);\n\n const durationsIndexes = values\n .map(value => value[status])\n .map((duration, index) => ({ index, duration }))\n .filter(({ duration }) => typeof duration !== 'undefined')\n .map(({ index }) => index);\n const durationsDense = values\n .map(value => value[status])\n .filter(\n (duration): duration is number => typeof duration !== 'undefined',\n );\n\n durationsDense.forEach(dur => allDurations.push(dur));\n\n const averages = durationsDense.map((_, i) =>\n average(\n durationsDense.slice(\n Math.max(i - averageWidth, 0),\n Math.min(i + averageWidth, durationsDense.length),\n ),\n ),\n );\n\n averages.forEach((avg, index) => {\n const key: Averagify<FilterStatusType> = `${status} avg`;\n values[durationsIndexes[index]][key] = avg;\n });\n });\n\n Object.assign(combinedAnalysis, makeCombinedAnalysis(analysis, allDurations));\n\n stage.stages.forEach(subStage => finalizeStage(subStage, options));\n}\n"],"names":[],"mappings":";;;;;AAmCO,SAAS,aAAA,CACd,OACA,OAAA,EACA;AACA,EAAA,MAAM,EAAE,YAAA,EAAc,SAAA,EAAU,GAAI,OAAA;AACpC,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAU,gBAAA,EAAiB,GAAI,KAAA;AAE/C,EAAA,IAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AACxB,IAAA,MAAM,WAAA,GAAc,IAAI,GAAA,CAAI,MAAA,CAAO,IAAI,CAAA,KAAA,KAAS,KAAA,CAAM,OAAO,CAAC,CAAA;AAE9D,IAAA,SAAA,CAAU,QAAQ,CAAA,KAAA,KAAS;AACzB,MAAA,IAAI,CAAC,WAAA,CAAY,GAAA,CAAI,KAAK,CAAA,EAAG;AAC3B,QAAA,MAAA,CAAO,IAAA,CAAK,EAAE,OAAA,EAAS,KAAA,EAAO,CAAA;AAAA,MAChC;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,MAAA,CAAO,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,CAAE,OAAA,GAAU,EAAE,OAAO,CAAA;AAE3C,EAAA,iBAAA,CAAkB,MAAM,CAAA;AAExB,EAAA,MAAM,eAA8B,EAAC;AAErC,EAAA,WAAA,CAAY,QAAQ,CAAA,MAAA,KAAU;AAC5B,IAAA,QAAA,CAAS,MAAM,CAAA,GAAI,WAAA,CAAY,MAAA,EAAQ,MAAM,CAAA;AAE7C,IAAA,MAAM,gBAAA,GAAmB,MAAA,CACtB,GAAA,CAAI,CAAA,KAAA,KAAS,KAAA,CAAM,MAAM,CAAC,CAAA,CAC1B,GAAA,CAAI,CAAC,QAAA,EAAU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m.js","sources":["../../../src/charts/logic/utils.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DateTime } from 'luxon';\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { ChartableStage } from '../types';\n\nexport function average(values: number[]): number {\n return !values.length\n ? 0\n : Math.round(values.reduce((prev, cur) => prev + cur, 0) / values.length);\n}\n\nexport function getOrSetStage(\n stages: Map<string, ChartableStage>,\n name: string,\n): ChartableStage {\n const stage = stages.get(name);\n if (stage) return stage;\n\n const newStage: ChartableStage = makeStage(name);\n stages.set(name, newStage);\n return newStage;\n}\n\nexport function makeStage(name: string): ChartableStage {\n return {\n analysis: {\n unknown: { avg: 0, med: 0, max: 0, min: 0 },\n enqueued: { avg: 0, med: 0, max: 0, min: 0 },\n scheduled: { avg: 0, med: 0, max: 0, min: 0 },\n running: { avg: 0, med: 0, max: 0, min: 0 },\n aborted: { avg: 0, med: 0, max: 0, min: 0 },\n succeeded: { avg: 0, med: 0, max: 0, min: 0 },\n failed: { avg: 0, med: 0, max: 0, min: 0 },\n stalled: { avg: 0, med: 0, max: 0, min: 0 },\n expired: { avg: 0, med: 0, max: 0, min: 0 },\n },\n combinedAnalysis: { avg: 0, med: 0, max: 0, min: 0 },\n statusSet: new Set<FilterStatusType>(),\n name,\n values: [],\n stages: new Map(),\n };\n}\n\nexport function startOfDay(date: number | Date) {\n if (typeof date === 'number') {\n return DateTime.fromMillis(date).startOf('day').toMillis();\n }\n return DateTime.fromJSDate(date).startOf('day').toMillis();\n}\n\nexport function sortTriggerReasons(reasons: Array<string>): Array<string> {\n return reasons.sort((a, b) => {\n if (a === 'manual') return -1;\n else if (b === 'manual') return 1;\n else if (a === 'scm') return -1;\n else if (b === 'scm') return 1;\n else if (a === 'other') return -1;\n else if (b === 'other') return 1;\n return a.localeCompare(b);\n });\n}\n\nexport function sortStatuses(statuses: Array<string>): Array<string> {\n return [\n ...statusTypes.filter(status => statuses.includes(status)),\n ...statuses\n .filter(status => !(statusTypes as Array<string>).includes(status))\n .sort((a, b) => a.localeCompare(b)),\n ];\n}\n"],"names":[],"mappings":";;;AAqBO,SAAS,QAAQ,MAA0B,EAAA;AAChD,EAAA,OAAO,CAAC,MAAO,CAAA,MAAA,GACX,CACA,GAAA,IAAA,CAAK,MAAM,MAAO,CAAA,MAAA,CAAO,CAAC,IAAA,EAAM,QAAQ,IAAO,GAAA,GAAA,EAAK,CAAC,CAAA,GAAI,OAAO,MAAM,CAAA;AAC5E;AAEgB,SAAA,aAAA,CACd,QACA,IACgB,EAAA;AAChB,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,GAAA,CAAI,IAAI,CAAA;AAC7B,EAAA,IAAI,OAAc,OAAA,KAAA;AAElB,EAAM,MAAA,QAAA,GAA2B,UAAU,IAAI,CAAA;AAC/C,EAAO,MAAA,CAAA,GAAA,CAAI,MAAM,QAAQ,CAAA;AACzB,EAAO,OAAA,QAAA;AACT;AAEO,SAAS,UAAU,IAA8B,EAAA;AACtD,EAAO,OAAA;AAAA,IACL,QAAU,EAAA;AAAA,MACR,OAAA,EAAS,EAAE,GAAK,EAAA,CAAA,EAAG,KAAK,CAAG,EAAA,GAAA,EAAK,CAAG,EAAA,GAAA,EAAK,CAAE,EAAA;AAAA,MAC1C,QAAA,EAAU,EAAE,GAAK,EAAA,CAAA,EAAG,KAAK,CAAG,EAAA,GAAA,EAAK,CAAG,EAAA,GAAA,EAAK,CAAE,EAAA;AAAA,MAC3C,SAAA,EAAW,EAAE,GAAK,EAAA,CAAA,EAAG,KAAK,CAAG,EAAA,GAAA,EAA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I,EAAE,OAAQ,CAAA,KAAK,EAAE,QAAS,EAAA;AAC3D;AAEO,SAAS,mBAAmB,OAAuC,EAAA;AACxE,EAAA,OAAO,OAAQ,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA;AAC5B,IAAI,IAAA,CAAA,KAAM,UAAiB,OAAA,CAAA,CAAA;AAAA,SAClB,IAAA,CAAA,KAAM,UAAiB,OAAA,CAAA;AAAA,SACvB,IAAA,CAAA,KAAM,OAAc,OAAA,CAAA,CAAA;AAAA,SACpB,IAAA,CAAA,KAAM,OAAc,OAAA,CAAA;AAAA,SACpB,IAAA,CAAA,KAAM,SAAgB,OAAA,CAAA,CAAA;AAAA,SACtB,IAAA,CAAA,KAAM,SAAgB,OAAA,CAAA;AAC/B,IAAO,OAAA,CAAA,CAAE,cAAc,CAAC,CAAA;AAAA,GACzB,CAAA;AACH;AAEO,SAAS,aAAa,QAAwC,EAAA;AACnE,EAAO,OAAA;AAAA,IACL,GAAG,WAAY,CAAA,MAAA,CAAO,YAAU,QAAS,CAAA,QAAA,CAAS,MAAM,CAAC,CAAA;AAAA,IACzD,GAAG,QACA,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA,CAAE,YAA8B,QAAS,CAAA,MAAM,CAAC,CAAA,CACjE,KAAK,CAAC,CAAA,EAAG,MAAM,CAAE,CAAA,aAAA,CAAc,CAAC,CAAC;AAAA,GACtC;AACF;;;;"}
1
+ {"version":3,"file":"utils.esm.js","sources":["../../../src/charts/logic/utils.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DateTime } from 'luxon';\n\nimport { FilterStatusType, statusTypes } from '../../apis/types';\nimport { ChartableStage } from '../types';\n\nexport function average(values: number[]): number {\n return !values.length\n ? 0\n : Math.round(values.reduce((prev, cur) => prev + cur, 0) / values.length);\n}\n\nexport function getOrSetStage(\n stages: Map<string, ChartableStage>,\n name: string,\n): ChartableStage {\n const stage = stages.get(name);\n if (stage) return stage;\n\n const newStage: ChartableStage = makeStage(name);\n stages.set(name, newStage);\n return newStage;\n}\n\nexport function makeStage(name: string): ChartableStage {\n return {\n analysis: {\n unknown: { avg: 0, med: 0, max: 0, min: 0 },\n enqueued: { avg: 0, med: 0, max: 0, min: 0 },\n scheduled: { avg: 0, med: 0, max: 0, min: 0 },\n running: { avg: 0, med: 0, max: 0, min: 0 },\n aborted: { avg: 0, med: 0, max: 0, min: 0 },\n succeeded: { avg: 0, med: 0, max: 0, min: 0 },\n failed: { avg: 0, med: 0, max: 0, min: 0 },\n stalled: { avg: 0, med: 0, max: 0, min: 0 },\n expired: { avg: 0, med: 0, max: 0, min: 0 },\n },\n combinedAnalysis: { avg: 0, med: 0, max: 0, min: 0 },\n statusSet: new Set<FilterStatusType>(),\n name,\n values: [],\n stages: new Map(),\n };\n}\n\nexport function startOfDay(date: number | Date) {\n if (typeof date === 'number') {\n return DateTime.fromMillis(date).startOf('day').toMillis();\n }\n return DateTime.fromJSDate(date).startOf('day').toMillis();\n}\n\nexport function sortTriggerReasons(reasons: Array<string>): Array<string> {\n return reasons.sort((a, b) => {\n if (a === 'manual') return -1;\n else if (b === 'manual') return 1;\n else if (a === 'scm') return -1;\n else if (b === 'scm') return 1;\n else if (a === 'other') return -1;\n else if (b === 'other') return 1;\n return a.localeCompare(b);\n });\n}\n\nexport function sortStatuses(statuses: Array<string>): Array<string> {\n return [\n ...statusTypes.filter(status => statuses.includes(status)),\n ...statuses\n .filter(status => !(statusTypes as Array<string>).includes(status))\n .sort((a, b) => a.localeCompare(b)),\n ];\n}\n"],"names":[],"mappings":";;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AAA,KAAM,OAAO,OAAO,CAAA;AAAA,SAAA,IACpB,CAAA,KAAM,SAAS,OAAO,EAAA;AAAA,SAAA,IACtB,CAAA,KAAM,SAAS,OAAO,CAAA;AAC/B,IAAA,OAAO,CAAA,CAAE,cAAc,CAAC,CAAA;AAAA,EAC1B,CAAC,CAAA;AACH;AAEO,SAAS,aAAa,QAAA,EAAwC;AACnE,EAAA,OAAO;AAAA,IACL,GAAG,WAAA,CAAY,MAAA,CAAO,YAAU,QAAA,CAAS,QAAA,CAAS,MAAM,CAAC,CAAA;AAAA,IACzD,GAAG,QAAA,CACA,MAAA,CAAO,CAAA,MAAA,KAAU,CAAE,YAA8B,QAAA,CAAS,MAAM,CAAC,CAAA,CACjE,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,CAAE,aAAA,CAAc,CAAC,CAAC;AAAA,GACtC;AACF;;;;"}
@@ -11,7 +11,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
11
11
  import { capitalize } from 'lodash';
12
12
  import { useZoom, useZoomArea } from './zoom.esm.js';
13
13
  import { statusTypes } from '../apis/types.esm.js';
14
- import { pickElements, formatDuration, tickFormatterX, tickFormatterY, tooltipValueFormatter, labelFormatter } from '../components/utils.esm.js';
14
+ import { pickElements, formatDuration, tickFormatterX, tickFormatterY, labelFormatter, tooltipValueFormatter } from '../components/utils.esm.js';
15
15
  import { statusColorMap, fireColors, colorStroke, colorStrokeAvg } from './colors.esm.js';
16
16
 
17
17
  const fullWidth = { width: "100%" };
@@ -1 +1 @@
1
- {"version":3,"file":"stage-chart.esm.js","sources":["../../src/charts/stage-chart.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSSProperties, Fragment, useMemo } from 'react';\nimport {\n Area,\n Bar,\n ComposedChart,\n XAxis,\n YAxis,\n YAxisProps,\n CartesianGrid,\n Legend,\n LegendProps,\n Line,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport Alert from '@material-ui/lab/Alert';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { capitalize } from 'lodash';\n\nimport { useZoom, useZoomArea } from './zoom';\nimport { CicdDefaults, statusTypes } from '../apis/types';\nimport { ChartableStage } from './types';\nimport {\n pickElements,\n labelFormatter,\n tickFormatterX,\n tickFormatterY,\n tooltipValueFormatter,\n formatDuration,\n} from '../components/utils';\nimport {\n statusColorMap,\n fireColors,\n colorStroke,\n colorStrokeAvg,\n} from './colors';\n\nconst fullWidth: CSSProperties = { width: '100%' };\nconst noUserSelect: CSSProperties = { userSelect: 'none' };\n\nconst transitionProps = { unmountOnExit: true };\n\nexport interface StageChartProps {\n stage: ChartableStage;\n\n chartTypes: CicdDefaults['chartTypes'];\n defaultCollapsed?: number;\n defaultHidden?: number;\n zeroYAxis?: boolean;\n}\n\nexport function StageChart(props: StageChartProps) {\n const { stage, ...chartOptions } = props;\n const {\n chartTypes,\n defaultCollapsed = 0,\n defaultHidden = 0,\n zeroYAxis = false,\n } = chartOptions;\n\n const { zoomFilterValues } = useZoom();\n const { zoomProps, getZoomArea } = useZoomArea();\n\n const ticks = useMemo(\n () => pickElements(stage.values, 8).map(val => val.__epoch),\n [stage.values],\n );\n const domainY = useMemo(\n () => [zeroYAxis ? 0 : 'auto', 'auto'] as YAxisProps['domain'],\n [zeroYAxis],\n );\n const statuses = useMemo(\n () => statusTypes.filter(status => stage.statusSet.has(status)),\n [stage.statusSet],\n );\n const legendPayload = useMemo(\n (): LegendProps['payload'] =>\n statuses.map(status => ({\n value: capitalize(status),\n type: 'line',\n id: status,\n color: statusColorMap[status],\n })),\n [statuses],\n );\n\n const subStages = useMemo(\n () =>\n new Map<string, ChartableStage>(\n [...stage.stages.entries()].filter(\n ([_name, subStage]) => subStage.combinedAnalysis.max > defaultHidden,\n ),\n ),\n [stage.stages, defaultHidden],\n );\n\n const zoomFilteredValues = useMemo(\n () => zoomFilterValues(stage.values),\n [stage.values, zoomFilterValues],\n );\n\n return stage.combinedAnalysis.max < defaultHidden ? null : (\n <Accordion\n defaultExpanded={stage.combinedAnalysis.max > defaultCollapsed}\n TransitionProps={transitionProps}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>\n {stage.name} (med {formatDuration(stage.combinedAnalysis.med)}, avg{' '}\n {formatDuration(stage.combinedAnalysis.avg)})\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {stage.values.length === 0 ? (\n <Alert severity=\"info\">No data</Alert>\n ) : (\n <Grid container direction=\"column\">\n <Grid item style={noUserSelect}>\n <ResponsiveContainer width=\"100%\" height={140}>\n <ComposedChart data={zoomFilteredValues} {...zoomProps}>\n <defs>\n <linearGradient id=\"colorDur\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n {fireColors.map(([percent, color]) => (\n <stop\n key={percent}\n offset={percent}\n stopColor={color}\n stopOpacity={0.8}\n />\n ))}\n </linearGradient>\n </defs>\n {statuses.length > 1 && <Legend payload={legendPayload} />}\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis\n dataKey=\"__epoch\"\n type=\"category\"\n ticks={ticks}\n tickFormatter={tickFormatterX}\n />\n <YAxis\n yAxisId={1}\n tickFormatter={tickFormatterY}\n type=\"number\"\n tickCount={5}\n name=\"Duration\"\n domain={domainY}\n />\n <YAxis\n yAxisId={2}\n orientation=\"right\"\n type=\"number\"\n tickCount={5}\n name=\"Count\"\n />\n <Tooltip\n formatter={tooltipValueFormatter}\n labelFormatter={labelFormatter}\n />\n {statuses.reverse().map(status => (\n <Fragment key={status}>\n {!chartTypes[status].includes('duration') ? null : (\n <>\n <Area\n isAnimationActive={false}\n yAxisId={1}\n type=\"monotone\"\n dataKey={status}\n stackId={status}\n stroke={\n statuses.length > 1\n ? statusColorMap[status]\n : colorStroke\n }\n fillOpacity={statuses.length > 1 ? 0.5 : 1}\n fill={\n statuses.length > 1\n ? statusColorMap[status]\n : 'url(#colorDur)'\n }\n connectNulls\n />\n <Line\n isAnimationActive={false}\n yAxisId={1}\n type=\"monotone\"\n dataKey={`${status} avg`}\n stroke={\n statuses.length > 1\n ? statusColorMap[status]\n : colorStrokeAvg\n }\n opacity={0.8}\n strokeWidth={2}\n dot={false}\n connectNulls\n />\n </>\n )}\n {!chartTypes[status].includes('count') ? null : (\n <Bar\n isAnimationActive={false}\n yAxisId={2}\n type=\"monotone\"\n dataKey={`${status} count`}\n stackId=\"1\"\n stroke={statusColorMap[status] ?? ''}\n fillOpacity={0.5}\n fill={statusColorMap[status] ?? ''}\n />\n )}\n </Fragment>\n ))}\n {getZoomArea({ yAxisId: 1 })}\n </ComposedChart>\n </ResponsiveContainer>\n </Grid>\n {subStages.size === 0 ? null : (\n <Grid item>\n <Accordion\n defaultExpanded={false}\n TransitionProps={transitionProps}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>Sub stages ({subStages.size})</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <div style={fullWidth}>\n {[...subStages.values()].map(subStage => (\n <StageChart\n key={subStage.name}\n {...chartOptions}\n stage={subStage}\n />\n ))}\n </div>\n </AccordionDetails>\n </Accordion>\n </Grid>\n )}\n </Grid>\n )}\n </AccordionDetails>\n </Accordion>\n );\n}\n"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;AA0DA,MAAM,SAAA,GAA2B,EAAE,KAAA,EAAO,MAAO,EAA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A,eAAA;AAAA,cAEjB,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,oBAAiB,UAAY,kBAAA,GAAA,CAAC,cAAe,EAAA,EAAA,CAAA,EAC5C,+BAAC,UAAW,EAAA,EAAA,QAAA,EAAA;AAAA,kBAAA,cAAA;AAAA,kBAAa,SAAU,CAAA,IAAA;AAAA,kBAAK;AAAA,iBAAA,EAAC,CAC3C,EAAA,CAAA;AAAA,gCACC,GAAA,CAAA,gBAAA,EAAA,EACC,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA,EAAI,KAAO,EAAA,SAAA,EACT,QAAC,EAAA,CAAA,GAAG,SAAU,CAAA,MAAA,EAAQ,CAAA,CAAE,IAAI,CAC3B,QAAA,qBAAA,GAAA;AAAA,kBAAC,UAAA;AAAA,kBAAA;AAAA,oBAEE,GAAG,YAAA;AAAA,oBACJ,KAAO,EAAA;AAAA,mBAAA;AAAA,kBAFF,QAAS,CAAA;AAAA,iBAIjB,GACH,CACF,EAAA;AAAA;AAAA;AAAA,WAEJ,EAAA;AAAA,SAAA,EAEJ,CAEJ,EAAA;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"stage-chart.esm.js","sources":["../../src/charts/stage-chart.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSSProperties, Fragment, useMemo } from 'react';\nimport {\n Area,\n Bar,\n ComposedChart,\n XAxis,\n YAxis,\n YAxisProps,\n CartesianGrid,\n Legend,\n LegendProps,\n Line,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport Alert from '@material-ui/lab/Alert';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { capitalize } from 'lodash';\n\nimport { useZoom, useZoomArea } from './zoom';\nimport { CicdDefaults, statusTypes } from '../apis/types';\nimport { ChartableStage } from './types';\nimport {\n pickElements,\n labelFormatter,\n tickFormatterX,\n tickFormatterY,\n tooltipValueFormatter,\n formatDuration,\n} from '../components/utils';\nimport {\n statusColorMap,\n fireColors,\n colorStroke,\n colorStrokeAvg,\n} from './colors';\n\nconst fullWidth: CSSProperties = { width: '100%' };\nconst noUserSelect: CSSProperties = { userSelect: 'none' };\n\nconst transitionProps = { unmountOnExit: true };\n\nexport interface StageChartProps {\n stage: ChartableStage;\n\n chartTypes: CicdDefaults['chartTypes'];\n defaultCollapsed?: number;\n defaultHidden?: number;\n zeroYAxis?: boolean;\n}\n\nexport function StageChart(props: StageChartProps) {\n const { stage, ...chartOptions } = props;\n const {\n chartTypes,\n defaultCollapsed = 0,\n defaultHidden = 0,\n zeroYAxis = false,\n } = chartOptions;\n\n const { zoomFilterValues } = useZoom();\n const { zoomProps, getZoomArea } = useZoomArea();\n\n const ticks = useMemo(\n () => pickElements(stage.values, 8).map(val => val.__epoch),\n [stage.values],\n );\n const domainY = useMemo(\n () => [zeroYAxis ? 0 : 'auto', 'auto'] as YAxisProps['domain'],\n [zeroYAxis],\n );\n const statuses = useMemo(\n () => statusTypes.filter(status => stage.statusSet.has(status)),\n [stage.statusSet],\n );\n const legendPayload = useMemo(\n (): LegendProps['payload'] =>\n statuses.map(status => ({\n value: capitalize(status),\n type: 'line',\n id: status,\n color: statusColorMap[status],\n })),\n [statuses],\n );\n\n const subStages = useMemo(\n () =>\n new Map<string, ChartableStage>(\n [...stage.stages.entries()].filter(\n ([_name, subStage]) => subStage.combinedAnalysis.max > defaultHidden,\n ),\n ),\n [stage.stages, defaultHidden],\n );\n\n const zoomFilteredValues = useMemo(\n () => zoomFilterValues(stage.values),\n [stage.values, zoomFilterValues],\n );\n\n return stage.combinedAnalysis.max < defaultHidden ? null : (\n <Accordion\n defaultExpanded={stage.combinedAnalysis.max > defaultCollapsed}\n TransitionProps={transitionProps}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>\n {stage.name} (med {formatDuration(stage.combinedAnalysis.med)}, avg{' '}\n {formatDuration(stage.combinedAnalysis.avg)})\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {stage.values.length === 0 ? (\n <Alert severity=\"info\">No data</Alert>\n ) : (\n <Grid container direction=\"column\">\n <Grid item style={noUserSelect}>\n <ResponsiveContainer width=\"100%\" height={140}>\n <ComposedChart data={zoomFilteredValues} {...zoomProps}>\n <defs>\n <linearGradient id=\"colorDur\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n {fireColors.map(([percent, color]) => (\n <stop\n key={percent}\n offset={percent}\n stopColor={color}\n stopOpacity={0.8}\n />\n ))}\n </linearGradient>\n </defs>\n {statuses.length > 1 && <Legend payload={legendPayload} />}\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis\n dataKey=\"__epoch\"\n type=\"category\"\n ticks={ticks}\n tickFormatter={tickFormatterX}\n />\n <YAxis\n yAxisId={1}\n tickFormatter={tickFormatterY}\n type=\"number\"\n tickCount={5}\n name=\"Duration\"\n domain={domainY}\n />\n <YAxis\n yAxisId={2}\n orientation=\"right\"\n type=\"number\"\n tickCount={5}\n name=\"Count\"\n />\n <Tooltip\n formatter={tooltipValueFormatter}\n labelFormatter={labelFormatter}\n />\n {statuses.reverse().map(status => (\n <Fragment key={status}>\n {!chartTypes[status].includes('duration') ? null : (\n <>\n <Area\n isAnimationActive={false}\n yAxisId={1}\n type=\"monotone\"\n dataKey={status}\n stackId={status}\n stroke={\n statuses.length > 1\n ? statusColorMap[status]\n : colorStroke\n }\n fillOpacity={statuses.length > 1 ? 0.5 : 1}\n fill={\n statuses.length > 1\n ? statusColorMap[status]\n : 'url(#colorDur)'\n }\n connectNulls\n />\n <Line\n isAnimationActive={false}\n yAxisId={1}\n type=\"monotone\"\n dataKey={`${status} avg`}\n stroke={\n statuses.length > 1\n ? statusColorMap[status]\n : colorStrokeAvg\n }\n opacity={0.8}\n strokeWidth={2}\n dot={false}\n connectNulls\n />\n </>\n )}\n {!chartTypes[status].includes('count') ? null : (\n <Bar\n isAnimationActive={false}\n yAxisId={2}\n type=\"monotone\"\n dataKey={`${status} count`}\n stackId=\"1\"\n stroke={statusColorMap[status] ?? ''}\n fillOpacity={0.5}\n fill={statusColorMap[status] ?? ''}\n />\n )}\n </Fragment>\n ))}\n {getZoomArea({ yAxisId: 1 })}\n </ComposedChart>\n </ResponsiveContainer>\n </Grid>\n {subStages.size === 0 ? null : (\n <Grid item>\n <Accordion\n defaultExpanded={false}\n TransitionProps={transitionProps}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>Sub stages ({subStages.size})</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <div style={fullWidth}>\n {[...subStages.values()].map(subStage => (\n <StageChart\n key={subStage.name}\n {...chartOptions}\n stage={subStage}\n />\n ))}\n </div>\n </AccordionDetails>\n </Accordion>\n </Grid>\n )}\n </Grid>\n )}\n </AccordionDetails>\n </Accordion>\n );\n}\n"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;AA0DA,MAAM,SAAA,GAA2B,EAAE,KAAA,EAAO,MAAA,EAAO;AACjD,MAAM,YAAA,GAA8B,EAAE,UAAA,EAAY,MAAA,EAAO;AAEzD,MAAM,eAAA,GAAkB,EAAE,aAAA,EAAe,IAAA,EAAK;AAWvC,SAAS,WAAW,KAAA,EAAwB;AACjD,EAAA,MAAM,EAAE,KAAA,EAAO,GAAG,YAAA,EAAa,GAAI,KAAA;AACnC,EAAA,MAA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,iBAAA,EAAC,CAAA,EAC3C,CAAA;AAAA,gCACA,GAAA,CAAC,gBAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,SAAA,EACT,QAAA,EAAA,CAAC,GAAG,SAAA,CAAU,MAAA,EAAQ,CAAA,CAAE,IAAI,CAAA,QAAA,qBAC3B,GAAA;AAAA,kBAAC,UAAA;AAAA,kBAAA;AAAA,oBAEE,GAAG,YAAA;AAAA,oBACJ,KAAA,EAAO;AAAA,mBAAA;AAAA,kBAFF,QAAA,CAAS;AAAA,iBAIjB,GACH,CAAA,EACF;AAAA;AAAA;AAAA,WACF,EACF;AAAA,SAAA,EAEJ,CAAA,EAEJ;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"status-chart.esm.js","sources":["../../src/charts/status-chart.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment, useMemo } from 'react';\nimport {\n Area,\n Bar,\n ComposedChart,\n XAxis,\n YAxis,\n CartesianGrid,\n Legend,\n LegendProps,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport Alert from '@material-ui/lab/Alert';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Typography from '@material-ui/core/Typography';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { capitalize } from 'lodash';\n\nimport { useZoom, useZoomArea } from './zoom';\nimport { FilterStatusType, TriggerReason } from '../apis/types';\nimport { labelFormatterWithoutTime, tickFormatterX } from '../components/utils';\nimport { statusColorMap, triggerColorMap } from './colors';\nimport { ChartableStagesAnalysis } from './types';\n\nexport interface StatusChartProps {\n analysis: ChartableStagesAnalysis;\n}\n\nexport function StatusChart(props: StatusChartProps) {\n const { analysis } = props;\n\n const { zoomFilterValues } = useZoom();\n const { zoomProps, getZoomArea } = useZoomArea();\n\n const values = useMemo(() => {\n return analysis.daily.values.map(value => {\n const totTriggers = analysis.daily.triggerReasons.reduce(\n (prev, cur) => prev + (value[cur as TriggerReason] ?? 0),\n 0,\n );\n\n if (!totTriggers) {\n return value;\n }\n\n return {\n ...value,\n ...Object.fromEntries(\n analysis.daily.triggerReasons.map(reason => [\n reason,\n (value[reason as TriggerReason] ?? 0) / totTriggers,\n ]),\n ),\n };\n });\n }, [analysis.daily]);\n\n const triggerReasonLegendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> =>\n analysis.daily.triggerReasons.map(reason => ({\n value: humanTriggerReason(reason),\n type: 'line',\n id: reason,\n color: triggerColorMap[reason as TriggerReason] ?? '',\n })),\n [analysis.daily.triggerReasons],\n );\n\n const statusesLegendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> =>\n analysis.daily.statuses.map(status => ({\n value: capitalize(status),\n type: 'line',\n id: status,\n color: statusColorMap[status as FilterStatusType] ?? '',\n })),\n [analysis.daily.statuses],\n );\n\n const legendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> => [\n ...triggerReasonLegendPayload,\n ...statusesLegendPayload,\n ],\n [statusesLegendPayload, triggerReasonLegendPayload],\n );\n\n const tooltipFormatter = useMemo(() => {\n const reasonSet = new Set(analysis.daily.triggerReasons);\n\n return (percentOrCount: number, name: string): [any, any] => {\n const label = reasonSet.has(name)\n ? humanTriggerReason(name)\n : capitalize(name);\n const valueText = reasonSet.has(name)\n ? `${(percentOrCount * 100).toFixed(0)}%`\n : percentOrCount;\n\n return [\n // TODO(Rugvip): Types don't allow returning elements, but it was here before so presumably works\n <Typography component=\"span\">\n {label}: {valueText}\n </Typography>,\n null,\n ];\n };\n }, [analysis.daily.triggerReasons]);\n\n const zoomFilteredValues = useMemo(\n () => zoomFilterValues(values),\n [values, zoomFilterValues],\n );\n\n const barSize = getBarSize(analysis.daily.values.length);\n\n return (\n <Accordion defaultExpanded={analysis.daily.statuses.length > 1}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>\n Build count per status over build trigger reason\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {values.length === 0 ? (\n <Alert severity=\"info\">No data</Alert>\n ) : (\n <ResponsiveContainer width=\"100%\" height={140}>\n <ComposedChart data={zoomFilteredValues} {...zoomProps}>\n <Legend payload={legendPayload} />\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis\n dataKey=\"__epoch\"\n type=\"category\"\n tickFormatter={tickFormatterX}\n />\n <YAxis yAxisId={1} type=\"number\" tickCount={5} name=\"Count\" />\n <YAxis yAxisId={2} type=\"number\" name=\"Triggers\" hide />\n <Tooltip\n labelFormatter={labelFormatterWithoutTime}\n formatter={tooltipFormatter}\n />\n {triggerReasonLegendPayload.map(reason => (\n <Fragment key={reason.id}>\n <Area\n isAnimationActive={false}\n type=\"monotone\"\n dataKey={reason.id!}\n stackId=\"triggers\"\n yAxisId={2}\n stroke={triggerColorMap[reason.id as TriggerReason] ?? ''}\n fillOpacity={0.5}\n fill={triggerColorMap[reason.id as TriggerReason] ?? ''}\n />\n </Fragment>\n ))}\n {[...analysis.daily.statuses].reverse().map(status => (\n <Fragment key={status}>\n <Bar\n isAnimationActive={false}\n type=\"monotone\"\n barSize={barSize}\n dataKey={status}\n stackId=\"statuses\"\n yAxisId={1}\n stroke={statusColorMap[status as FilterStatusType] ?? ''}\n fillOpacity={0.8}\n fill={statusColorMap[status as FilterStatusType] ?? ''}\n />\n </Fragment>\n ))}\n {getZoomArea({ yAxisId: 1 })}\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </AccordionDetails>\n </Accordion>\n );\n}\n\nfunction humanTriggerReason(reason: string): string {\n if ((reason as TriggerReason) === 'manual') {\n return 'Triggered manually';\n } else if ((reason as TriggerReason) === 'scm') {\n return 'Triggered by SCM';\n } else if ((reason as TriggerReason) === 'internal') {\n return 'Triggered internally';\n } else if ((reason as TriggerReason) === 'other') {\n return 'Triggered by another reason';\n }\n return `Triggered by ${reason}`;\n}\n\nfunction getBarSize(count: number): number {\n if (count < 20) {\n return 10;\n } else if (count < 40) {\n return 8;\n }\n return 5;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA+CO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAM,MAAA,EAAE,UAAa,GAAA,KAAA;AAErB,EAAM,MAAA,EAAE,gBAAiB,EAAA,GAAI,OAAQ,EAAA;AACrC,EAAA,MAAM,EAAE,SAAA,EAAW,WAAY,EAAA,GAAI,WAAY,EAAA;AAE/C,EAAM,MAAA,MAAA,GAAS,QAAQ,MAAM;AAC3B,IAAA,OAAO,QAAS,CAAA,KAAA,CAAM,MAAO,CAAA,GAAA,CAAI,CAAS,KAAA,KAAA;AACxC,MAAM,MAAA,WAAA,GAAc,QAAS,CAAA,KAAA,CAAM,cAAe,CAAA,MAAA;AAAA,QAChD,CAAC,IAAM,EAAA,GAAA,KAAQ,IAAQ,IAAA,KAAA,CAAM,GAAoB,CAAK,IAAA,CAAA,CAAA;AAAA,QACtD;AAAA,OACF;AAEA,MAAA,IAAI,CAAC,WAAa,EAAA;AAChB,QAAO,OAAA,KAAA;AAAA;AAGT,MAAO,OAAA;AAAA,QACL,GAAG,KAAA;AAAA,QACH,GAAG,MAAO,CAAA,WAAA;AAAA,UACR,QAAS,CAAA,KAAA,CAAM,cAAe,CAAA,GAAA,CAAI,CAAU,MAAA,KAAA;AAAA,YAC1C,MAAA;AAAA,YACC,CAAA,KAAA,CAAM,MAAuB,CAAA,IAAK,CAAK,IAAA;AAAA,WACzC;AAAA;AACH,OACF;AAAA,KACD,C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/status-chart.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment, useMemo } from 'react';\nimport {\n Area,\n Bar,\n ComposedChart,\n XAxis,\n YAxis,\n CartesianGrid,\n Legend,\n LegendProps,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport Alert from '@material-ui/lab/Alert';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Typography from '@material-ui/core/Typography';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { capitalize } from 'lodash';\n\nimport { useZoom, useZoomArea } from './zoom';\nimport { FilterStatusType, TriggerReason } from '../apis/types';\nimport { labelFormatterWithoutTime, tickFormatterX } from '../components/utils';\nimport { statusColorMap, triggerColorMap } from './colors';\nimport { ChartableStagesAnalysis } from './types';\n\nexport interface StatusChartProps {\n analysis: ChartableStagesAnalysis;\n}\n\nexport function StatusChart(props: StatusChartProps) {\n const { analysis } = props;\n\n const { zoomFilterValues } = useZoom();\n const { zoomProps, getZoomArea } = useZoomArea();\n\n const values = useMemo(() => {\n return analysis.daily.values.map(value => {\n const totTriggers = analysis.daily.triggerReasons.reduce(\n (prev, cur) => prev + (value[cur as TriggerReason] ?? 0),\n 0,\n );\n\n if (!totTriggers) {\n return value;\n }\n\n return {\n ...value,\n ...Object.fromEntries(\n analysis.daily.triggerReasons.map(reason => [\n reason,\n (value[reason as TriggerReason] ?? 0) / totTriggers,\n ]),\n ),\n };\n });\n }, [analysis.daily]);\n\n const triggerReasonLegendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> =>\n analysis.daily.triggerReasons.map(reason => ({\n value: humanTriggerReason(reason),\n type: 'line',\n id: reason,\n color: triggerColorMap[reason as TriggerReason] ?? '',\n })),\n [analysis.daily.triggerReasons],\n );\n\n const statusesLegendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> =>\n analysis.daily.statuses.map(status => ({\n value: capitalize(status),\n type: 'line',\n id: status,\n color: statusColorMap[status as FilterStatusType] ?? '',\n })),\n [analysis.daily.statuses],\n );\n\n const legendPayload = useMemo(\n (): NonNullable<LegendProps['payload']> => [\n ...triggerReasonLegendPayload,\n ...statusesLegendPayload,\n ],\n [statusesLegendPayload, triggerReasonLegendPayload],\n );\n\n const tooltipFormatter = useMemo(() => {\n const reasonSet = new Set(analysis.daily.triggerReasons);\n\n return (percentOrCount: number, name: string): [any, any] => {\n const label = reasonSet.has(name)\n ? humanTriggerReason(name)\n : capitalize(name);\n const valueText = reasonSet.has(name)\n ? `${(percentOrCount * 100).toFixed(0)}%`\n : percentOrCount;\n\n return [\n // TODO(Rugvip): Types don't allow returning elements, but it was here before so presumably works\n <Typography component=\"span\">\n {label}: {valueText}\n </Typography>,\n null,\n ];\n };\n }, [analysis.daily.triggerReasons]);\n\n const zoomFilteredValues = useMemo(\n () => zoomFilterValues(values),\n [values, zoomFilterValues],\n );\n\n const barSize = getBarSize(analysis.daily.values.length);\n\n return (\n <Accordion defaultExpanded={analysis.daily.statuses.length > 1}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <Typography>\n Build count per status over build trigger reason\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {values.length === 0 ? (\n <Alert severity=\"info\">No data</Alert>\n ) : (\n <ResponsiveContainer width=\"100%\" height={140}>\n <ComposedChart data={zoomFilteredValues} {...zoomProps}>\n <Legend payload={legendPayload} />\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis\n dataKey=\"__epoch\"\n type=\"category\"\n tickFormatter={tickFormatterX}\n />\n <YAxis yAxisId={1} type=\"number\" tickCount={5} name=\"Count\" />\n <YAxis yAxisId={2} type=\"number\" name=\"Triggers\" hide />\n <Tooltip\n labelFormatter={labelFormatterWithoutTime}\n formatter={tooltipFormatter}\n />\n {triggerReasonLegendPayload.map(reason => (\n <Fragment key={reason.id}>\n <Area\n isAnimationActive={false}\n type=\"monotone\"\n dataKey={reason.id!}\n stackId=\"triggers\"\n yAxisId={2}\n stroke={triggerColorMap[reason.id as TriggerReason] ?? ''}\n fillOpacity={0.5}\n fill={triggerColorMap[reason.id as TriggerReason] ?? ''}\n />\n </Fragment>\n ))}\n {[...analysis.daily.statuses].reverse().map(status => (\n <Fragment key={status}>\n <Bar\n isAnimationActive={false}\n type=\"monotone\"\n barSize={barSize}\n dataKey={status}\n stackId=\"statuses\"\n yAxisId={1}\n stroke={statusColorMap[status as FilterStatusType] ?? ''}\n fillOpacity={0.8}\n fill={statusColorMap[status as FilterStatusType] ?? ''}\n />\n </Fragment>\n ))}\n {getZoomArea({ yAxisId: 1 })}\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </AccordionDetails>\n </Accordion>\n );\n}\n\nfunction humanTriggerReason(reason: string): string {\n if ((reason as TriggerReason) === 'manual') {\n return 'Triggered manually';\n } else if ((reason as TriggerReason) === 'scm') {\n return 'Triggered by SCM';\n } else if ((reason as TriggerReason) === 'internal') {\n return 'Triggered internally';\n } else if ((reason as TriggerReason) === 'other') {\n return 'Triggered by another reason';\n }\n return `Triggered by ${reason}`;\n}\n\nfunction getBarSize(count: number): number {\n if (count < 20) {\n return 10;\n } else if (count < 40) {\n return 8;\n }\n return 5;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA+CO,SAAS,YAAY,KAAA,EAAyB;AACnD,EAAA,MAAM,EAAE,UAAS,GAAI,KAAA;AAErB,EAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,OAAA,EAAQ;AACrC,EAAA,MAAM,EAAE,SAAA,EAAW,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