Randomize sort order of user IDs
This commit is contained in:
parent
1134b0991a
commit
04457b8912
@ -44,6 +44,16 @@ try {
|
|||||||
const userIdsResult = await client.queryObject("SELECT id FROM users");
|
const userIdsResult = await client.queryObject("SELECT id FROM users");
|
||||||
const userIds = userIdsResult.rows.map((row) => row.id);
|
const userIds = userIdsResult.rows.map((row) => row.id);
|
||||||
|
|
||||||
|
// Shuffle userIds array to randomize processing order
|
||||||
|
function shuffleArray(array) {
|
||||||
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[array[i], array[j]] = [array[j], array[i]]; // Swap elements
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
shuffleArray(userIds);
|
||||||
|
|
||||||
// CSV file path
|
// CSV file path
|
||||||
const csvFilePath = "./daily-stats.csv";
|
const csvFilePath = "./daily-stats.csv";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user