forked from dora-metrics/developer-intelligence-prototype
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert deployment-frequency data components
- Loading branch information
Showing
10 changed files
with
97 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// app/dashboard/deployment-frequency-data.tsx | ||
import { getDaysBetweenDates } from '@/lib/date-funcs'; | ||
import { DeploymentFrequencyChart } from '@/components/deployment-frequency/chart'; | ||
import { DeploymentFrequencyTable } from '@/components/deployment-frequency/table'; | ||
import { TableIcon } from 'lucide-react'; | ||
|
||
interface DeploymentFrequencyData { | ||
issue_id: string; | ||
timestamp: number; | ||
// Add other relevant fields from your API response here | ||
} | ||
|
||
async function fetchDeploymentFrequency(appName: string, from: Date, to: Date): Promise<DeploymentFrequencyData[]> { | ||
const reqUrl = `${process.env.PELORUS_API_URL}/sdp/deployment_frequency/${appName}/data?range=${getDaysBetweenDates({ to, from })}d&start=${Math.floor(to.getTime() / 1000)}`; | ||
console.log(`df Req URL: ${reqUrl}`); | ||
|
||
const response = await fetch(reqUrl); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to fetch Lead Time for Change data"); | ||
} | ||
|
||
const data: DeploymentFrequencyData[] = await response.json(); | ||
return data.sort((d1, d2) => (d1.timestamp > d2.timestamp ? 1 : d1.timestamp < d2.timestamp ? -1 : 0)); | ||
} | ||
|
||
export default async function DeploymentFrequencyData({ appName, dateRange }: { appName: string; dateRange: { from: Date; to: Date } }) { | ||
const data = await fetchDeploymentFrequency(appName, dateRange.from, dateRange.to); | ||
|
||
return ( | ||
<> | ||
<div className="h-64"> | ||
<DeploymentFrequencyChart dfData={data} /> | ||
</div> | ||
<div className="mt-8"> | ||
<h2 className="flex items-center gap-2 mb-4 font-semibold dark:text-white"> | ||
<TableIcon /> | ||
Deployments | ||
</h2> | ||
<DeploymentFrequencyTable dfData={data} /> | ||
</div> | ||
</> | ||
); | ||
} |
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,30 @@ | ||
import { getDaysBetweenDates } from '@/lib/date-funcs'; | ||
import { DeploymentFrequencyTabTrigger } from '@/components/deployment-frequency/tab-trigger'; | ||
|
||
interface DeploymentFrequency { | ||
df: number; | ||
last: number; | ||
// Add other relevant fields from your API response here | ||
} | ||
|
||
async function fetchDeploymentFrequency(appName: string, from: Date, to: Date): Promise<DeploymentFrequency[]> { | ||
const reqUrl = `${process.env.PELORUS_API_URL}/sdp/deployment_frequency/${appName}?range=${getDaysBetweenDates({ to, from })}d&start=${Math.floor(to.getTime() / 1000)}`; | ||
console.log(`LTFC Req URL: ${reqUrl}`); | ||
|
||
const response = await fetch(reqUrl); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to fetch Deployment Frequency numbers"); | ||
} | ||
|
||
const data: DeploymentFrequency[] = await response.json(); | ||
return data | ||
} | ||
|
||
export default async function DeploymentFrequency({ appName, dateRange }: { appName: string; dateRange: { from: Date; to: Date } }) { | ||
const data = await fetchDeploymentFrequency(appName, dateRange.from, dateRange.to); | ||
|
||
return ( | ||
<DeploymentFrequencyTabTrigger appName={appName} data={data} dateRange={dateRange} /> | ||
) | ||
} |
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
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 was deleted.
Oops, something went wrong.
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