Make response data refresh interval configurable
This commit is contained in:
@@ -8,6 +8,7 @@ import Legend from "./components/Legend";
|
|||||||
import QRCode from "./components/QRCode";
|
import QRCode from "./components/QRCode";
|
||||||
import { WaffleChart } from "./components/WaffleChart";
|
import { WaffleChart } from "./components/WaffleChart";
|
||||||
|
|
||||||
|
import { config } from "./config";
|
||||||
import { getSampleData } from "./lib/data";
|
import { getSampleData } from "./lib/data";
|
||||||
import "./styles/App.scss";
|
import "./styles/App.scss";
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ function App() {
|
|||||||
queryKey: ["responses"],
|
queryKey: ["responses"],
|
||||||
// queryFn: fetchGoogleSheet,
|
// queryFn: fetchGoogleSheet,
|
||||||
queryFn: getSampleData,
|
queryFn: getSampleData,
|
||||||
refetchInterval: 1 * 1000, // Refresh every 5 seconds
|
refetchInterval: config.refreshIntervalSeconds * 1000,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (metadataQuery.isPending || responseQuery.isPending)
|
if (metadataQuery.isPending || responseQuery.isPending)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export const config = {
|
|||||||
chartHeight: 50,
|
chartHeight: 50,
|
||||||
dotShape: "rect", // "circle" or "rect"
|
dotShape: "rect", // "circle" or "rect"
|
||||||
renderXAxis: true, // Whether to render the x-axis
|
renderXAxis: true, // Whether to render the x-axis
|
||||||
|
refreshIntervalSeconds: 1, // Refresh interval for response data in seconds
|
||||||
};
|
};
|
||||||
|
|
||||||
// Color scheme for Likert scale responses
|
// Color scheme for Likert scale responses
|
||||||
|
|||||||
@@ -22,8 +22,5 @@ export async function getSampleData(): Promise<ResponseData[]> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Simulate a delay to mimic fetching actual data
|
return Promise.resolve(sampleData);
|
||||||
return new Promise<ResponseData[]>((resolve) => {
|
|
||||||
setTimeout(() => resolve(sampleData), 500);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user