Skip to content

Commit

Permalink
Fetch alerts with open status only
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-serendipity committed Mar 12, 2024
1 parent a67a900 commit c706b8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/entities/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,3 @@ export const toAlert = (
: undefined,
createdAt: dependabotAlert.created_at,
})

export const isActiveAlert = (dependabotAlert: DependabotAlert): boolean => {
if (
dependabotAlert.dismissed_at === null &&
dependabotAlert.fixed_at === null
) {
return true
}
return false
}
11 changes: 5 additions & 6 deletions src/fetch-alerts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Octokit } from '@octokit/rest'

import { Alert, isActiveAlert, toAlert } from './entities'
import { Alert, toAlert } from './entities'

export const fetchAlerts = async (
gitHubPersonalAccessToken: string,
Expand All @@ -18,13 +18,12 @@ export const fetchAlerts = async (
const response = await octokit.dependabot.listAlertsForRepo({
owner: repositoryOwner,
repo: repositoryName,
state: 'open',
severity,
per_page: count,
})
const alerts: Alert[] = response.data
.filter((dependabotAlert) => isActiveAlert(dependabotAlert))
.map((dependabotAlert) =>
toAlert(dependabotAlert, repositoryName, repositoryOwner),
)
const alerts: Alert[] = response.data.map((dependabotAlert) =>
toAlert(dependabotAlert, repositoryName, repositoryOwner),
)
return alerts
}

0 comments on commit c706b8c

Please sign in to comment.