-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fetching of labels marked as
incidents
(#9)
Added the ability to fetch labels on the cron job and add them to a new array named `incidents`. Restructured the report file (and renamed the file to stop it from causing problems). Updated the interface to show the new incidents using a timeline. Prettified the footer ## Summary - **New Features** - Introduced `IncidentManager` class for managing GitHub incidents. - Added a new Svelte component to display recent incidents in a timeline format. - Enhanced page functionality with conditional rendering of incidents. - Expanded data retrieval capabilities with the addition of incident loading functions. - **Improvements** - Updated artifact and incident handling to streamline processes. - Enhanced layout of the component footer for better user experience. - Improved the data structure for incident tracking and reporting. - **Bug Fixes** - Refined artifact management methods for better performance and accuracy. - Modified test case structures to accommodate new data formats.
- Loading branch information
Showing
14 changed files
with
767 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ | |
.idea | ||
|
||
# Report files | ||
report.json | ||
report.zip | ||
reports.json | ||
reports.zip | ||
log/*.json | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import moment from "moment"; | ||
import { ReportFile } from "../types"; | ||
import { ActionLogger, GitHubClient, Repo } from "./types"; | ||
|
||
export class IncidentManager { | ||
constructor( | ||
private readonly api: GitHubClient, | ||
private readonly logger: ActionLogger, | ||
private readonly labelName: string = "incident", | ||
|
||
) { } | ||
|
||
async obtainPastIncidents(repo: Repo, maxAge: number): Promise<ReportFile["incidents"]> { | ||
this.logger.info("Searching for previous incidents") | ||
const issues = await this.api.rest.issues.listForRepo({ ...repo }); | ||
this.logger.info(`Found ${issues.data.length} issues`); | ||
const incidents: ReportFile["incidents"] = [] | ||
|
||
for (const issue of issues.data) { | ||
if (issue.labels.some(l => { | ||
if (typeof l === "string") { | ||
return l.toLocaleUpperCase() === this.labelName.toLocaleUpperCase(); | ||
} else { | ||
return l.name?.toLocaleUpperCase() === this.labelName.toLocaleUpperCase(); | ||
} | ||
})) { | ||
const creationDate = moment(issue.created_at); | ||
if (Math.abs(creationDate.diff(moment.now(), "days")) < maxAge) { | ||
incidents.push({ date: creationDate.unix(), title: issue.title, open: issue.state === "open" }); | ||
} else { | ||
this.logger.info(`Issue ${issue.title} is older than ${maxAge} days`); | ||
} | ||
} | ||
} | ||
|
||
this.logger.info(`${incidents.length} of this issues were incidents`); | ||
|
||
return incidents; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import type { ReportFile } from '$lib/types'; | ||
import moment from 'moment'; | ||
export let incidents: ReportFile['incidents']; | ||
</script> | ||
|
||
<div class=""> | ||
<h1 class="text-2xl font-bold text-left">Recent incidents</h1> | ||
<ul class="timeline timeline-vertical mt-4 lg:mt10"> | ||
{#each incidents as incident, i} | ||
<li> | ||
{#if i > 0} | ||
<hr class:bg-primary={incident.open} /> | ||
{/if} | ||
<div class="timeline-start">{moment.unix(incident.date).format('MMM Do YY')}</div> | ||
<div class="timeline-middle" class:text-primary={incident.open}> | ||
<div class="badge" class:badge-primary={incident.open}> | ||
{#if incident.open} | ||
⤫ | ||
{:else} | ||
✓ | ||
{/if} | ||
</div> | ||
</div> | ||
<div class="timeline-end timeline-box">{incident.title}</div> | ||
|
||
{#if i < incidents.length - 1} | ||
<hr class:bg-primary={incident.open} /> | ||
{/if} | ||
</li> | ||
{/each} | ||
</ul> | ||
</div> |
Oops, something went wrong.