Skip to content

Commit dd9ca80

Browse files
committed
Solution for unique numbers
1 parent deab3e6 commit dd9ca80

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

extensions/ql-vscode/src/stories/variant-analysis/VariantAnalysisAnalyzedRepos.stories.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,22 @@ Example.args = {
125125
};
126126

127127
faker.seed(42);
128-
const uniqueStore = {};
128+
const uniqueNumbers = [...Array(1000).keys()].sort(() => Math.random() - 0.5);
129129

130130
const manyScannedRepos = Array.from({ length: 1000 }, (_, i) => {
131131
const mockedScannedRepo = createMockScannedRepo();
132+
const randomInt = uniqueNumbers.pop();
133+
const uniqueId =
134+
randomInt === undefined ? Math.floor(Math.random() * 100000) : randomInt;
132135

133136
return {
134137
...mockedScannedRepo,
135138
analysisStatus: VariantAnalysisRepoStatus.Succeeded,
136139
resultCount: faker.number.int({ min: 0, max: 1000 }),
137140
repository: {
138141
...mockedScannedRepo.repository,
139-
// We need to ensure the ID is unique for React keys
140-
id: faker.helpers.unique(faker.number.int, [], {
141-
store: uniqueStore,
142-
}),
143-
fullName: `octodemo/${faker.helpers.unique(faker.word.sample, [], {
144-
store: uniqueStore,
145-
})}`,
142+
id: uniqueId,
143+
fullName: `octodemo/${uniqueId}`,
146144
},
147145
};
148146
});

0 commit comments

Comments
 (0)