From 911c18b08ed5226354e00594ae308b620578de8b Mon Sep 17 00:00:00 2001
From: Bjarke Madsen <bjarke@nordu.net>
Date: Tue, 21 Mar 2023 11:02:51 +0100
Subject: [PATCH] Follow API documentation for budget
---
compendium_v2/routes/budget.py | 3 +--
webapp/src/Schema.tsx | 4 ----
webapp/src/pages/DataAnalysis.tsx | 15 ++++++---------
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/compendium_v2/routes/budget.py b/compendium_v2/routes/budget.py
index e2f1d4ce..681c70aa 100644
--- a/compendium_v2/routes/budget.py
+++ b/compendium_v2/routes/budget.py
@@ -78,8 +78,7 @@ def budget_view() -> Any:
entries = sorted([_extract_data(entry)
for entry in session.query(model.BudgetEntry)],
key=lambda d: (d['BUDGET_YEAR'], d['NREN']))
- dict_obj = {"data": entries}
- return jsonify(dict_obj)
+ return jsonify(entries)
@routes.route('/migration', methods=['GET'])
diff --git a/webapp/src/Schema.tsx b/webapp/src/Schema.tsx
index 873d3083..b66f038b 100644
--- a/webapp/src/Schema.tsx
+++ b/webapp/src/Schema.tsx
@@ -26,10 +26,6 @@ export interface BudgetMatrix {
title: string
}
-export interface BudgetAPI {
- data: [Budget]
-}
-
export interface Budget {
BUDGET: string,
BUDGET_YEAR: number,
diff --git a/webapp/src/pages/DataAnalysis.tsx b/webapp/src/pages/DataAnalysis.tsx
index 1ec10a65..cdea542b 100644
--- a/webapp/src/pages/DataAnalysis.tsx
+++ b/webapp/src/pages/DataAnalysis.tsx
@@ -1,11 +1,8 @@
import React, { ReactElement, useEffect, useState } from 'react';
import { Accordion, Col, Container, ListGroup, Row } from "react-bootstrap";
-import BarGraph from "../components/graphing/BarGraph";
import LineGraph from "../components/graphing/LineGraph";
-import { BudgetMatrix, DataEntrySection, Budget,BudgetAPI } from "../Schema";
-// import {evaluateInteractionItems} from "chart.js/dist/core/core.interaction";
-import barGraph from "../components/graphing/BarGraph";
+import { BudgetMatrix, DataEntrySection, Budget } from "../Schema";
export const options = {
@@ -67,17 +64,17 @@ function DataAnalysis(): ReactElement {
const loadData = async () => {
console.log("budgetResponse "+ budgetResponse)
if (budgetResponse == undefined) {
- api<BudgetAPI>('/api/budget/', {})
- .then((budget: BudgetAPI) => {
- console.log('budget.data :', budget.data)
+ api<Budget[]>('/api/budget/', {})
+ .then((budget: Budget[]) => {
+ console.log('budget.data :', budget)
console.log('budget :', budget)
const entry = dataEntrySection?.items.find(i => i.id == selectedDataEntry)
console.log(selectedDataEntry, dataEntrySection, entry)
if (entry)
options.plugins.title.text = entry.title;
- setBudget(budget.data)
+ setBudget(budget)
console.log("budgetResponse after api "+ budgetResponse)
- convertToBudgetPerYearDataResponse(budget.data)
+ convertToBudgetPerYearDataResponse(budget)
})
.catch(error => {
console.log(`Error fetching from API: ${error}`);
--
GitLab