Skip to content

Commit

Permalink
added prediction second increase dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Apr 10, 2023
1 parent aa6c763 commit a37257b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const AIModelsList = (props) => {
field: "description",
headerName: "Description",
flex: 1,
renderCell: (params) => {
return (
<Tooltip title={params.value} placement="right">
<span>{params.value}</span>
</Tooltip>
);
},
},
{
field: "epochs",
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/components/Layout/Start/Prediction/Prediction.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { GeoJSON } from "react-leaflet";
const Prediction = () => {
const { id } = useParams();
const [error, setError] = useState(false);
const [apiCallInProgress, setApiCallInProgress] = useState(false);

const [map, setMap] = useState(null);
const [zoom, setZoom] = useState(0);
const [responseTime, setResponseTime] = useState(0);
Expand All @@ -28,6 +30,20 @@ const Prediction = () => {
]);
const [josmEnabled, setJosmEnabled] = useState(false);

useEffect(() => {
if (!apiCallInProgress) {
return;
}

const timer = setInterval(() => {
setResponseTime((prevResponseTime) => prevResponseTime + 1);
}, 1000);

return () => {
clearInterval(timer);
};
}, [apiCallInProgress]);

useEffect(() => {
getModel();
}, []);
Expand Down Expand Up @@ -80,6 +96,7 @@ const Prediction = () => {
data: predictions,
isLoading: predictionLoading,
} = useMutation(async () => {
setApiCallInProgress(true);
const headers = {
"access-token": accessToken,
};
Expand All @@ -98,6 +115,7 @@ const Prediction = () => {
const res = await axios.post(`/prediction/`, body, { headers });
const endTime = new Date().getTime(); // measure end time
setResponseTime((endTime - startTime) / 1000); // calculate and store response time in seconds
setApiCallInProgress(false);
if (res.error) {
setError(
`${res.error.response.statusText}, ${JSON.stringify(
Expand Down

0 comments on commit a37257b

Please sign in to comment.