Skip to content

Commit 586b0c8

Browse files
fix data fetching issue
1 parent 6d0f68e commit 586b0c8

31 files changed

+1616
-10296
lines changed

TODO.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

fetch-test-results.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ async function main() {
160160
// a deep copy.
161161
const newContent = JSON.parse(JSON.stringify(existingTestResultsData));
162162

163+
const today = new Date();
164+
163165
for (const week of WEEKS) {
166+
if (new Date(week.to) >= today) {
167+
break;
168+
}
169+
164170
console.log("");
165171
console.log(`--- Getting results for week ${week.from} to ${week.to} ---`);
166172

@@ -171,7 +177,9 @@ async function main() {
171177
console.log("");
172178
console.log(`--- Feature: ${feature.id} ---`);
173179

174-
if (existingTestResultsData[indexDate] && existingTestResultsData[indexDate][feature.id] && !feature.forceUpdateResults) {
180+
const existingResult = existingTestResultsData[indexDate]?.[feature.id];
181+
const hasBeenFetched = existingResult && (existingResult.sha != null || existingResult.date != null);
182+
if (hasBeenFetched && !feature.forceUpdateResults) {
175183
console.log(`Already have data for ${feature.id} for this date. Skipping.`);
176184
continue;
177185
}
@@ -194,6 +202,17 @@ async function main() {
194202
}
195203
}
196204

205+
// Remove entries for features that are no longer tracked.
206+
const featureIds = new Set(features.map(f => f.id));
207+
for (const date of Object.keys(newContent)) {
208+
for (const featureId of Object.keys(newContent[date])) {
209+
if (!featureIds.has(featureId)) {
210+
console.log(`Removing stale feature "${featureId}" from ${date}`);
211+
delete newContent[date][featureId];
212+
}
213+
}
214+
}
215+
197216
// Sort the entire content by date and write it again to the file.
198217
const sortedContent = Object.keys(newContent)
199218
.sort((dateStrA, dateStrB) => {

0 commit comments

Comments
 (0)