Skip to content

Commit

Permalink
Merge pull request hotosm#118 from hotosm/116-bug-user-name-is-not-up…
Browse files Browse the repository at this point in the history
…dating

avoiding cache of useQuery by adding the id to query name
  • Loading branch information
omranlm authored Jun 14, 2023
2 parents c2fa2ef + c122bde commit 18a0af4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import FeedbackToast from "./FeedbackToast";
import FeedbackPopup from "./FeedbackPopup";
import FormGroup from "@mui/material/FormGroup";


const AIModelEditor = (props) => {
let { id } = useParams();
const [error, setError] = useState(null);
Expand Down Expand Up @@ -72,9 +71,13 @@ const AIModelEditor = (props) => {
setPopupOpen(true);
};

const { data, isLoading, refetch } = useQuery("getModelById", getModelById, {
refetchInterval: 60000,
});
const { data, isLoading, refetch } = useQuery(
"getModelById" + id,
getModelById,
{
refetchInterval: 60000,
}
);
const getFeedbackCount = async () => {
try {
const response = await axios.get(
Expand Down Expand Up @@ -111,7 +114,7 @@ const AIModelEditor = (props) => {
const body = {
epochs: epochs,
batch_size: batchSize,
freeze_layers:freezeLayers,
freeze_layers: freezeLayers,
model: id,
zoom_level: zoomLevel,
description: description,
Expand All @@ -124,8 +127,8 @@ const AIModelEditor = (props) => {
if (res.error) {
setError(
res.error.response.statusText +
" / " +
JSON.stringify(res.error.response.data)
" / " +
JSON.stringify(res.error.response.data)
);
return;
}
Expand Down Expand Up @@ -292,8 +295,6 @@ const AIModelEditor = (props) => {
</FormControl>
</Grid>



<Grid item xs={12} md={6}>
<TextField
id="model-description"
Expand Down Expand Up @@ -329,7 +330,7 @@ const AIModelEditor = (props) => {
/>
</FormGroup>
</FormControl>
</Grid>
</Grid>

<Grid item xs={12} md={6}></Grid>
<Grid item xs={12} md={6}></Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import { useQuery } from "react-query";
import axios from "../../../../axios";

Expand All @@ -9,9 +9,9 @@ const DatasetCurrent = (props) => {
// if (!accessToken) return;
try {
const res = await axios.get(`/workspace/dataset_${props.datasetId}/`);

console.log(`/workspace/dataset_${props.datasetId}/`, res);
if (res.error) {
// setMapError(res.error.response.statusText);
console.log("isError", res.error);
} else {
return res.data;
}
Expand All @@ -20,15 +20,24 @@ const DatasetCurrent = (props) => {
} finally {
}
};
const { data, isLoading } = useQuery("getDatasetSepcs", getDatasetSepcs, {
refetchInterval: 120000,
});
const { data, isLoading } = useQuery(
"getDatasetSepcs" + props.datasetId,
getDatasetSepcs,
{
refetchInterval: 30000,
}
);
useEffect(() => {
return () => {};
}, []);

return (
<>
{isLoading && "Loading ..."}
{data && data.dir && data.dir.input && (
<span>{data.dir.input.len - 1} images</span>
)}
{data === undefined && <span>Not downloaded yet</span>}
</>
);
};
Expand Down

0 comments on commit 18a0af4

Please sign in to comment.