libroadcast-cli 2.11.0 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { exit } from "node:process";
2
2
  import { client, msgCommonErrorHelp, handleApiResponse, checkTokenScopes, sleep, } from "../utils/commandHandler.js";
3
3
  import { getBroadcastRound } from "../utils/getInfoBroadcast.js";
4
4
  import cl from "../utils/colors.js";
5
+ import { splitIdsIntoGroups } from "../utils/splitTools.js";
5
6
  const setLichessGames = (round, games) => handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
6
7
  params: {
7
8
  path: { broadcastRoundId: round.id },
@@ -27,10 +28,6 @@ const getBulkIds = (bulkID) => client
27
28
  console.error(cl.red(`Error fetching bulk pairing data: ${error.message}`));
28
29
  return [];
29
30
  });
30
- const splitIdsIntoGroups = (broadcastsIds, gameIds) => gameIds.reduce((groups, id, index) => {
31
- groups[index % broadcastsIds.length].push(id);
32
- return groups;
33
- }, broadcastsIds.map(() => []));
34
31
  export const bulkIDsMultiCommand = async (args) => {
35
32
  await checkTokenScopes();
36
33
  const bulkID = args.shift();
@@ -2,6 +2,7 @@ import { exit } from "node:process";
2
2
  import { client, msgCommonErrorHelp, handleApiResponse, checkTokenScopes, sleep, } from "../utils/commandHandler.js";
3
3
  import { getBroadcastRound } from "../utils/getInfoBroadcast.js";
4
4
  import cl from "../utils/colors.js";
5
+ import { splitIdsIntoGroups } from "../utils/splitTools.js";
5
6
  const setLichessGames = (round, games) => handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
6
7
  params: {
7
8
  path: { broadcastRoundId: round.id },
@@ -12,10 +13,6 @@ const setLichessGames = (round, games) => handleApiResponse(client.POST("/broadc
12
13
  syncIds: games,
13
14
  },
14
15
  }), `Successfully set games for round ${cl.whiteBold(round.id)} to ${cl.whiteBold(games)}.`, `Error setting games for round ${cl.whiteBold(round.id)}`);
15
- const splitIdsIntoGroups = (broadcastsIds, gameIds) => gameIds.reduce((groups, id, index) => {
16
- groups[index % broadcastsIds.length].push(id);
17
- return groups;
18
- }, broadcastsIds.map(() => []));
19
16
  export const setLichessGamesMultiCommand = async (args) => {
20
17
  await checkTokenScopes();
21
18
  const bIds = args.shift()?.split(" ");
@@ -0,0 +1,14 @@
1
+ export const splitIdsIntoGroups = (broadcastsIds, gameIds) => {
2
+ const chunkSize = 64;
3
+ const groups = broadcastsIds.map(() => []);
4
+ for (let i = 0; i < broadcastsIds.length; i++) {
5
+ const start = i * chunkSize;
6
+ if (i === broadcastsIds.length - 1) {
7
+ groups[i] = gameIds.slice(start);
8
+ }
9
+ else {
10
+ groups[i] = gameIds.slice(start, start + chunkSize);
11
+ }
12
+ }
13
+ return groups;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libroadcast-cli",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "CLI to help with broadcast maintenance on Lichess",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [