tt-help-cli-ycl 1.3.41 → 1.3.44

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.
@@ -6,22 +6,7 @@ import { join, dirname } from "path";
6
6
  import { fileURLToPath } from "url";
7
7
  import { spawn } from "child_process";
8
8
  import { createStore } from "./data-store.js";
9
-
10
- const TARGET_LOCATIONS = [
11
- "CZ",
12
- "GR",
13
- "HU",
14
- "PT",
15
- "ES",
16
- "PL",
17
- "NL",
18
- "BE",
19
- "DE",
20
- "FR",
21
- "IT",
22
- "IE",
23
- "AT",
24
- ];
9
+ import { DEFAULT_TARGET_LOCATIONS } from "../lib/target-locations.js";
25
10
 
26
11
  const __filename = fileURLToPath(import.meta.url);
27
12
 
@@ -40,7 +25,7 @@ const __dirname = dirname(__filename);
40
25
  const publicDir = join(__dirname, "public");
41
26
 
42
27
  function computeStatsIncremental(st) {
43
- return st.getDashboardStats(TARGET_LOCATIONS);
28
+ return st.getDashboardStats(DEFAULT_TARGET_LOCATIONS);
44
29
  }
45
30
 
46
31
  function readBody(req) {
@@ -328,7 +313,7 @@ export function startWatchServer(dataAnchor, port = 3000, existingStore) {
328
313
 
329
314
  if (req.method === "GET" && routePath === "/api/stats") {
330
315
  const stats = computeStatsIncremental(store);
331
- stats.targetLocations = TARGET_LOCATIONS;
316
+ stats.targetLocations = DEFAULT_TARGET_LOCATIONS;
332
317
  sendJSON(res, 200, stats);
333
318
  return;
334
319
  }
@@ -459,7 +444,7 @@ export function startWatchServer(dataAnchor, port = 3000, existingStore) {
459
444
  }
460
445
 
461
446
  if (req.method === "GET" && routePath === "/api/target-users") {
462
- const targetResult = store.getTargetUsers(TARGET_LOCATIONS);
447
+ const targetResult = store.getTargetUsers(DEFAULT_TARGET_LOCATIONS);
463
448
  const targets = targetResult.users;
464
449
  if (req.headers["accept"]?.includes("text/csv")) {
465
450
  const columns = [
@@ -499,6 +484,89 @@ export function startWatchServer(dataAnchor, port = 3000, existingStore) {
499
484
  return;
500
485
  }
501
486
 
487
+ if (req.method === "GET" && routePath === "/api/pending-by-country") {
488
+ const countries = store.getPendingByCountry();
489
+ sendJSON(res, 200, { countries });
490
+ return;
491
+ }
492
+
493
+ if (req.method === "GET" && routePath === "/api/user-update-by-country") {
494
+ const countries = store.getUserUpdateByCountry();
495
+ sendJSON(res, 200, { countries });
496
+ return;
497
+ }
498
+
499
+ if (
500
+ req.method === "GET" &&
501
+ routePath === "/api/attach-stuck-by-country"
502
+ ) {
503
+ const countries = store.getAttachStuckByCountry();
504
+ sendJSON(res, 200, { countries });
505
+ return;
506
+ }
507
+
508
+ if (req.method === "GET" && routePath === "/api/raw-by-country") {
509
+ const countries = store.getRawByCountry();
510
+ sendJSON(res, 200, { countries });
511
+ return;
512
+ }
513
+
514
+ if (req.method === "GET" && routePath === "/api/raw-jobs") {
515
+ const result = store.getRawJobsPage({
516
+ search: params.search,
517
+ location: params.location,
518
+ limit: params.limit,
519
+ offset: params.offset,
520
+ });
521
+ sendJSON(res, 200, result);
522
+ return;
523
+ }
524
+
525
+ if (req.method === "POST" && routePath === "/api/jobs/move-to-raw") {
526
+ try {
527
+ const body = await readBody(req);
528
+ const result = store.moveJobsToRawByCountry(body.scope, body.country);
529
+ if (result.error) {
530
+ sendJSON(res, 400, result);
531
+ return;
532
+ }
533
+ sendJSON(res, 200, result);
534
+ } catch (e) {
535
+ sendJSON(res, 400, { error: e.message });
536
+ }
537
+ return;
538
+ }
539
+
540
+ if (req.method === "POST" && routePath === "/api/raw-jobs/restore") {
541
+ try {
542
+ const body = await readBody(req);
543
+ const result = store.restoreRawJobsByCountry(body.country);
544
+ if (result.error) {
545
+ sendJSON(res, 400, result);
546
+ return;
547
+ }
548
+ sendJSON(res, 200, result);
549
+ } catch (e) {
550
+ sendJSON(res, 400, { error: e.message });
551
+ }
552
+ return;
553
+ }
554
+
555
+ if (req.method === "POST" && routePath === "/api/attach-stuck/restore") {
556
+ try {
557
+ const body = await readBody(req);
558
+ const result = store.restoreAttachStuckByCountry(body.country);
559
+ if (result.error) {
560
+ sendJSON(res, 400, result);
561
+ return;
562
+ }
563
+ sendJSON(res, 200, result);
564
+ } catch (e) {
565
+ sendJSON(res, 400, { error: e.message });
566
+ }
567
+ return;
568
+ }
569
+
502
570
  if (
503
571
  req.method === "DELETE" &&
504
572
  routePath.startsWith("/api/client-error/")
@@ -540,7 +608,7 @@ export function startWatchServer(dataAnchor, port = 3000, existingStore) {
540
608
  targetLocation: params.targetLocation,
541
609
  limit: params.limit,
542
610
  offset: params.offset,
543
- targetLocations: TARGET_LOCATIONS,
611
+ targetLocations: DEFAULT_TARGET_LOCATIONS,
544
612
  });
545
613
 
546
614
  if (params.view === "light") {