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 { WaffleChart } from "./components/WaffleChart";
|
||||
|
||||
import { config } from "./config";
|
||||
import { getSampleData } from "./lib/data";
|
||||
import "./styles/App.scss";
|
||||
|
||||
@@ -20,7 +21,7 @@ function App() {
|
||||
queryKey: ["responses"],
|
||||
// queryFn: fetchGoogleSheet,
|
||||
queryFn: getSampleData,
|
||||
refetchInterval: 1 * 1000, // Refresh every 5 seconds
|
||||
refetchInterval: config.refreshIntervalSeconds * 1000,
|
||||
});
|
||||
|
||||
if (metadataQuery.isPending || responseQuery.isPending)
|
||||
|
||||
@@ -11,6 +11,7 @@ export const config = {
|
||||
chartHeight: 50,
|
||||
dotShape: "rect", // "circle" or "rect"
|
||||
renderXAxis: true, // Whether to render the x-axis
|
||||
refreshIntervalSeconds: 1, // Refresh interval for response data in seconds
|
||||
};
|
||||
|
||||
// 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 new Promise<ResponseData[]>((resolve) => {
|
||||
setTimeout(() => resolve(sampleData), 500);
|
||||
});
|
||||
return Promise.resolve(sampleData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user