Skip to content

Commit

Permalink
removed getMetricData method
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Lopez committed May 22, 2024
1 parent 6d55db2 commit 6e8a340
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ describe('CreateScenariosComponent', () => {
'PlanStateService',
{
getScenario: fakeGetScenario,
getMetricData: of(null),
updateStateWithShapes: undefined,
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/interface/src/app/plan/scenario-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export function processScenarioResultsToChartData(
): ChartData[] {
const {
scenario_priorities: priorities = [],
scenario_output_fields: outputFields = [],
scenario_output_fields: secondary = [],
} = scenarioConfig;
const relevantFields = new Set([...outputFields, ...priorities]);
const outputFields = new Set([...secondary, ...priorities]);

return metrics.reduce((acc: ChartData[], metric) => {
if (relevantFields.has(metric.metric_name)) {
if (outputFields.has(metric.metric_name)) {
const metricData = scenarioResults.result.features.map(
(featureCollection) => featureCollection.properties[metric.metric_name]
);
Expand Down
4 changes: 4 additions & 0 deletions src/interface/src/app/services/metrics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class MetricsService {

constructor(private http: HttpClient) {}

/**
* gets a flat list of metrics for a given region
* @param region
*/
public getMetricsForRegion(region: Region) {
if (this.conditions[region] !== null) {
return of(this.conditions[region] as MetricConfig[]);
Expand Down
7 changes: 0 additions & 7 deletions src/interface/src/app/services/plan-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ export class PlanStateService {
);
}

getMetricData(metric_paths: any) {
return this.scenarioService.getMetricData(
metric_paths,
this.planRegion$.value
);
}

/**
* Updates planRegion and treatmentGoalsConfig if value is a valid Region
*/
Expand Down
19 changes: 1 addition & 18 deletions src/interface/src/app/services/scenario.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { catchError, Observable, take } from 'rxjs';
import {
Region,
regionToString,
Scenario,
SCENARIO_STATUS,
ScenarioConfig,
} from '@types';
import { Scenario, SCENARIO_STATUS, ScenarioConfig } from '@types';
import { CreateScenarioError } from './errors';
import { environment } from '../../environments/environment';

Expand Down Expand Up @@ -145,17 +139,6 @@ export class ScenarioService {
);
}

/** Gets Metric Data For Scenario Output Fields */
getMetricData(metric_paths: any, region: Region): Observable<any> {
const url = environment.backend_endpoint.concat(
'/conditions/metrics/?region_name=' +
`${regionToString(region)}` +
'&metric_paths=' +
JSON.stringify(metric_paths)
);
return this.http.get<any>(url).pipe(take(1));
}

private convertConfigToScenario(config: ScenarioConfig): any {
return {
question_id: config.treatment_question!.id,
Expand Down

0 comments on commit 6e8a340

Please sign in to comment.