mirror of
https://github.com/OkaeriPoland/okaeri-timings.git
synced 2026-01-18 03:28:20 +01:00
Add report parsing time to the parse result
This commit is contained in:
@@ -11,6 +11,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -26,6 +28,7 @@ public class ParseController {
|
|||||||
return ResponseEntity.badRequest().body(Map.of("error", "Expected text/csv, got: " + file.getContentType()));
|
return ResponseEntity.badRequest().body(Map.of("error", "Expected text/csv, got: " + file.getContentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instant start = Instant.now();
|
||||||
String content = new String(file.getBytes(), StandardCharsets.UTF_8);
|
String content = new String(file.getBytes(), StandardCharsets.UTF_8);
|
||||||
String[] lines = content.split("\r?\n");
|
String[] lines = content.split("\r?\n");
|
||||||
|
|
||||||
@@ -81,10 +84,15 @@ public class ParseController {
|
|||||||
throw new RuntimeException("Invalid report");
|
throw new RuntimeException("Invalid report");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Object> report = Map.of(
|
||||||
|
"took", (Duration.between(start, Instant.now()))
|
||||||
|
);
|
||||||
|
|
||||||
return ResponseEntity.ok(Map.of(
|
return ResponseEntity.ok(Map.of(
|
||||||
"meta", metadata,
|
"meta", metadata,
|
||||||
"header", header,
|
"header", header,
|
||||||
"data", records
|
"data", records,
|
||||||
|
"report", report
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export default {
|
|||||||
this.report = await this.axios.post('/v1/parse', formData, {headers: {'Content-Type': 'multipart/form-data'}})
|
this.report = await this.axios.post('/v1/parse', formData, {headers: {'Content-Type': 'multipart/form-data'}})
|
||||||
.then((response) => response.data)
|
.then((response) => response.data)
|
||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
|
console.log(`Report parsing took ${this.report.took}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup: function () {
|
setup: function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user