@fluxhub/fluxhub-lib 19.0.115 → 19.0.116

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.
@@ -32445,67 +32445,55 @@ class win_log_v2 {
32445
32445
  });
32446
32446
  }
32447
32447
  calculateCompletedStepsFromLogs() {
32448
- // Extract unique step numbers from logs (operazione field may contain step info)
32449
- // Common step numbers: 10, 20, 30, 40, 50, etc. (900+ are final states)
32450
32448
  const stepNumbers = new Set();
32451
- const transitions = [];
32452
- // Parse logs to find step transitions
32453
- let previousStep = null;
32449
+ const transitionsMap = new Map();
32450
+ // Process logs to extract transitions from liv_ini → liv_fin
32454
32451
  this.logs.forEach((log) => {
32455
- // Check if this is a workflow transition log
32456
- // Usually identified by operazione containing step information
32457
- const operazione = log.operazione || '';
32458
- // Try to extract "from step X to step Y" pattern
32459
- // Common patterns: "10 → 20", "Step 10 to 20", "Passaggio da 10 a 20"
32460
- const transitionMatch = operazione.match(/(\d+)\s*(?:→|->|to|a)\s*(\d+)/i);
32461
- if (transitionMatch) {
32462
- const fromStep = parseInt(transitionMatch[1], 10);
32463
- const toStep = parseInt(transitionMatch[2], 10);
32452
+ // Check if this log has transition data
32453
+ if (log.liv_ini != null && log.liv_fin != null) {
32454
+ const fromStep = parseInt(log.liv_ini, 10);
32455
+ const toStep = parseInt(log.liv_fin, 10);
32456
+ // Validate step numbers (10-890 range, exclude final states 900+)
32464
32457
  if (fromStep >= 10 && fromStep < 900 && toStep >= 10) {
32465
32458
  stepNumbers.add(fromStep);
32466
32459
  if (toStep < 900) {
32467
32460
  stepNumbers.add(toStep);
32468
32461
  }
32469
- // Add transition data
32470
- transitions.push({
32471
- fromStep: fromStep,
32472
- toStep: toStep,
32473
- user: log.nc || log.username || 'Sistema',
32474
- date: this.formatDate(log.data_creazione)
32475
- });
32476
- previousStep = toStep;
32477
- }
32478
- }
32479
- else {
32480
- // Try to extract single step number
32481
- const matches = operazione.match(/\b(\d+)\b/g);
32482
- if (matches) {
32483
- matches.forEach((match) => {
32484
- const stepNum = parseInt(match, 10);
32485
- if (stepNum >= 10 && stepNum < 900) {
32486
- stepNumbers.add(stepNum);
32487
- // If we have a previous step, create transition
32488
- if (previousStep !== null && previousStep !== stepNum) {
32489
- transitions.push({
32490
- fromStep: previousStep,
32491
- toStep: stepNum,
32492
- user: log.nc || log.username || 'Sistema',
32493
- date: this.formatDate(log.data_creazione)
32494
- });
32495
- }
32496
- previousStep = stepNum;
32497
- }
32498
- });
32462
+ // Create unique key for this transition
32463
+ const transitionKey = `${fromStep}_${toStep}`;
32464
+ const timestamp = new Date(log.data_evento || log.data_creazione).getTime();
32465
+ // Check if we already have this transition
32466
+ const existing = transitionsMap.get(transitionKey);
32467
+ // Keep only the most recent transition for each fromStep → toStep
32468
+ if (!existing || timestamp > existing.timestamp) {
32469
+ transitionsMap.set(transitionKey, {
32470
+ fromStep: fromStep,
32471
+ toStep: toStep,
32472
+ user: log.idp || log.nc || log.username || 'Sistema',
32473
+ date: this.formatDate(log.data_evento || log.data_creazione),
32474
+ timestamp: timestamp
32475
+ });
32476
+ console.log(`Transition: ${fromStep} → ${toStep} by ${log.idp || log.nc} on ${this.formatDate(log.data_evento || log.data_creazione)}`);
32477
+ }
32499
32478
  }
32500
32479
  }
32501
32480
  });
32502
- // Add all steps less than current step (assumption: sequential workflow)
32503
- // Common step increments: 10, 20, 30, 40, 50...
32481
+ // Add all steps less than current step (fallback for sequential workflow)
32504
32482
  for (let step = 10; step < this.currentStep && step < 900; step += 10) {
32505
32483
  stepNumbers.add(step);
32506
32484
  }
32485
+ // Convert map to array (without timestamp)
32486
+ const transitions = Array.from(transitionsMap.values()).map(t => ({
32487
+ fromStep: t.fromStep,
32488
+ toStep: t.toStep,
32489
+ user: t.user,
32490
+ date: t.date
32491
+ }));
32507
32492
  this.completedSteps = Array.from(stepNumbers).sort((a, b) => a - b);
32508
32493
  this.transitionData = transitions;
32494
+ console.log('Completed steps:', this.completedSteps);
32495
+ console.log('Transitions found:', transitions.length);
32496
+ console.log('Transition data:', this.transitionData);
32509
32497
  }
32510
32498
  formatDate(dateStr) {
32511
32499
  if (!dateStr)