From 3f55a536269a3233b66421416b91b268a368e8b1 Mon Sep 17 00:00:00 2001 From: Matt Gunter Date: Thu, 23 Jan 2025 14:14:49 -0500 Subject: [PATCH] value modeling working --- .../value-modeling.component.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/copilot/value-modeling/value-modeling.component.ts b/frontend/src/app/main/copilot/value-modeling/value-modeling.component.ts index 927dd90..7febe1c 100644 --- a/frontend/src/app/main/copilot/value-modeling/value-modeling.component.ts +++ b/frontend/src/app/main/copilot/value-modeling/value-modeling.component.ts @@ -203,7 +203,7 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { try { // Update form value correctly // this.form.get('current.seats')?.setValue('100'); // Use the proper FormControl path - this.gridObject.current.asOfDate = new Date("2025-01-22T01:06:00.001Z").getTime(); + this.gridObject.current.asOfDate = new Date().getTime(); const currentAsStrings = this.convertMetricStateToString(this.gridObject.current); //console.log('AsOfDate as string:', currentAsStrings.asOfDate); @@ -276,6 +276,7 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { //This needs to be a deep copy. If we do a shallow copy, the gridObjectSaved will be updated whenever the gridObject is updated. this.gridObjectSaved = JSON.parse(JSON.stringify(this.gridObject)); console.log('7. Saved gridObject:', this.gridObjectSaved); + //targetService.saveTarget(this.gridObject.target); } private updateFormFromGridObject() { @@ -418,13 +419,16 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { try { // get settings data - this.settingsService.getAllSettings().subscribe((settings) => { + const settings$ = this.settingsService.getAllSettings(); + const settings = await lastValueFrom(settings$); + + console.log('Settings data:', settings); this.devCostPerYear = settings.devCostPerYear || 0; this.developerCount = settings.developerCount || 0; this.hoursPerYear = settings.hoursPerYear || 0; this.percentCoding = settings.percentCoding || 0; this.percentTimeSaved = settings.percentTimeSaved || 0; - }); + gridObject.max.seats = this.developerCount; gridObject.max.adoptedDevs = this.developerCount; @@ -432,6 +436,11 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { gridObject.max.dailySuggestions = 150; gridObject.max.dailyChatTurns = 50; gridObject.max.weeklyPRSummaries = 5; + gridObject.max.weeklyTimeSaved = (this.hoursPerYear * this.percentCoding/100 * this.percentTimeSaved/100)/50; + console.log('Max values set to developer count:', gridObject.max); + + const metrics$ = this.metricsService.getMetrics(); + const metrics = await lastValueFrom(metrics$); // Get adoptions data const adoptions$ = this.adoptionService.getAdoptions({ daysInactive: 30 }); @@ -443,7 +452,7 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { const bestRecord = adoptions.reduce((acc, item) => { const itemDate = typeof item.date === 'string' || typeof item.date === 'number' ? new Date(item.date) : new Date(); if (itemDate.getTime() < (Date.now() - (this.clickCounter * 1000 * 60 * 60 * 24))) { // Get adoption records that are n days old, where n is the number of times the buttons have been clicked - console.log(item.date.toString()) + // console.log(item.date.toString()) if (item.totalActive > acc.totalActive) { // Find the highest number of active developers within 36 hrs of the clickcounter date return item; } @@ -486,7 +495,7 @@ export class ValueModelingComponent implements OnInit, AfterViewInit { } - console.log('update Current Values2: Updated gridObject.current:', gridObject); + console.log('update Current and Max Values: Updated gridObject', gridObject); this.gridObject = gridObject; } catch (error) { console.error('updateCurrentValues: Error fetching values', error);