fix(api): align frontend with REST contracts
This commit is contained in:
@@ -11,8 +11,7 @@ describe("burst detection request", () => {
|
||||
const state = createBurstDetectionAnalysisParametersState();
|
||||
state.schemeName = " latest-case ";
|
||||
|
||||
expect(buildBurstDetectionRequest(state, "fengyang")).toEqual({
|
||||
network: "fengyang",
|
||||
expect(buildBurstDetectionRequest(state)).toEqual({
|
||||
scheme_name: "latest-case",
|
||||
sampling_interval_minutes: 15,
|
||||
});
|
||||
@@ -33,10 +32,8 @@ describe("burst detection request", () => {
|
||||
samplingIntervalMinutes: 30,
|
||||
samplingIntervalSource: "manual",
|
||||
},
|
||||
"fengyang",
|
||||
),
|
||||
).toEqual({
|
||||
network: "fengyang",
|
||||
scheme_name: "history-case",
|
||||
sampling_interval_minutes: 30,
|
||||
target_time: targetTime.toISOString(),
|
||||
|
||||
@@ -92,9 +92,7 @@ export const resolvePressureSamplingInterval = (items: ScadaInfoItem[]) => {
|
||||
|
||||
export const buildBurstDetectionRequest = (
|
||||
parameters: BurstDetectionAnalysisParametersState,
|
||||
network: string,
|
||||
) => ({
|
||||
network,
|
||||
scheme_name: parameters.schemeName.trim(),
|
||||
sampling_interval_minutes: parameters.samplingIntervalMinutes,
|
||||
...(parameters.detectionMode === "historical" && parameters.targetTime
|
||||
@@ -129,7 +127,7 @@ const AnalysisParameters: React.FC<Props> = ({
|
||||
let active = true;
|
||||
setFrequencyLoading(true);
|
||||
api
|
||||
.get("/api/v1/getallscadainfo/", { params: { network: NETWORK_NAME } })
|
||||
.get("/api/v1/scada-info")
|
||||
.then((response) => {
|
||||
if (!active) return;
|
||||
const interval = resolvePressureSamplingInterval(
|
||||
@@ -186,8 +184,8 @@ const AnalysisParameters: React.FC<Props> = ({
|
||||
|
||||
try {
|
||||
const response = await api.post(
|
||||
"/api/v1/burst-detection/detect/",
|
||||
buildBurstDetectionRequest(parametersState, NETWORK_NAME),
|
||||
"/api/v1/burst-detections",
|
||||
buildBurstDetectionRequest(parametersState),
|
||||
);
|
||||
onResult(response.data as BurstDetectionResult);
|
||||
open?.({
|
||||
|
||||
@@ -131,7 +131,6 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
setLoading(true);
|
||||
try {
|
||||
const params: Record<string, string> = {
|
||||
network: NETWORK_NAME,
|
||||
scheme_type: "burst_detection",
|
||||
};
|
||||
if (!queryAll && queryDate) {
|
||||
@@ -162,7 +161,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
try {
|
||||
const response = await api.get(
|
||||
`/api/v1/schemes/${encodeURIComponent(schemeName)}`,
|
||||
{ params: { network: NETWORK_NAME, scheme_type: "burst_detection" } },
|
||||
{ params: { scheme_type: "burst_detection" } },
|
||||
);
|
||||
const schemeRecord = response.data as BurstDetectionSchemeRecord & {
|
||||
result_payload?: BurstDetectionResult;
|
||||
|
||||
Reference in New Issue
Block a user