Skip to content

Commit 5e294b7

Browse files
committed
Allow for easy local dev modifications to fetch script
1 parent 12f2e69 commit 5e294b7

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ yarn-error.log*
3636
*.tsbuildinfo
3737
next-env.d.ts
3838

39+
/job_stats.json

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Follow these steps to set up the development environment for the Kata Containers
7272
3. **Run the development server**:
7373
Start the Next.js development server with hot-reloading enabled.
7474
```bash
75+
node scripts/fetch-ci-nightly-data.js > job_stats.json
7576
npm run dev
7677
```
7778

@@ -96,5 +97,5 @@ Follow these steps to set up the development environment for the Kata Containers
9697
- **Fetch CI Nightly Data**:
9798
The `fetch-ci-nightly-data.js` script can be executed manually to pull the latest CI test data from the Kata Containers repository:
9899
```bash
99-
node scripts/fetch-ci-nightly-data.js
100+
node scripts/fetch-ci-nightly-data.js > job_stats.json
100101
```

pages/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ export default function Home() {
1313
useEffect(() => {
1414
const fetchData = async () => {
1515
let data = {};
16-
const response = await fetch(
17-
"https://raw.githubusercontent.com/kata-containers/kata-containers.github.io" +
18-
"/refs/heads/latest-dashboard-data/data/job_stats.json"
19-
);
20-
data = await response.json();
16+
17+
if (process.env.NODE_ENV === "development") {
18+
data = (await import("../job_stats.json")).default;
19+
} else {
20+
const response = await fetch(
21+
"https://raw.githubusercontent.com/kata-containers/kata-containers.github.io" +
22+
"/refs/heads/latest-dashboard-data/data/job_stats.json"
23+
);
24+
data = await response.json();
25+
}
2126

2227
try {
2328
const jobData = Object.keys(data).map((key) => {

0 commit comments

Comments
 (0)