diff --git a/app.config.timestamp_1742289695505.js b/app.config.timestamp_1742289695505.js
new file mode 100644
index 0000000..3ede07e
--- /dev/null
+++ b/app.config.timestamp_1742289695505.js
@@ -0,0 +1,33 @@
+// app.config.ts
+import { defineConfig } from "@solidjs/start/config";
+import { configDefaults } from "vitest/config";
+import autoprefixer from "autoprefixer";
+import solidSvg from "vite-plugin-solid-svg";
+var app_config_default = defineConfig({
+ server: {
+ preset: "aws-lambda",
+ inlineDynamicImports: true
+ },
+ vite: {
+ assetsInclude: ["**/*.md"],
+ plugins: [
+ solidSvg()
+ ],
+ css: {
+ postcss: {
+ plugins: [autoprefixer({})]
+ }
+ },
+ test: {
+ exclude: [...configDefaults.exclude, "cdk/*"],
+ environment: "jsdom",
+ globals: true,
+ setupFiles: ["node_modules/@testing-library/jest-dom/vitest"],
+ isolate: false
+ }
+ },
+ middleware: "./src/middleware/index.ts"
+});
+export {
+ app_config_default as default
+};
diff --git a/app.config.timestamp_1742289695514.js b/app.config.timestamp_1742289695514.js
new file mode 100644
index 0000000..3ede07e
--- /dev/null
+++ b/app.config.timestamp_1742289695514.js
@@ -0,0 +1,33 @@
+// app.config.ts
+import { defineConfig } from "@solidjs/start/config";
+import { configDefaults } from "vitest/config";
+import autoprefixer from "autoprefixer";
+import solidSvg from "vite-plugin-solid-svg";
+var app_config_default = defineConfig({
+ server: {
+ preset: "aws-lambda",
+ inlineDynamicImports: true
+ },
+ vite: {
+ assetsInclude: ["**/*.md"],
+ plugins: [
+ solidSvg()
+ ],
+ css: {
+ postcss: {
+ plugins: [autoprefixer({})]
+ }
+ },
+ test: {
+ exclude: [...configDefaults.exclude, "cdk/*"],
+ environment: "jsdom",
+ globals: true,
+ setupFiles: ["node_modules/@testing-library/jest-dom/vitest"],
+ isolate: false
+ }
+ },
+ middleware: "./src/middleware/index.ts"
+});
+export {
+ app_config_default as default
+};
diff --git a/src/client/index.tsx b/src/client/index.tsx
index 7a0917e..8b50a9d 100644
--- a/src/client/index.tsx
+++ b/src/client/index.tsx
@@ -25,13 +25,14 @@ export async function fetchLocation(locationsId: number) {
async function fetchSensorMeasurementsDownload(
sensorsId: number,
+ rollup: string,
datetimeFrom: string,
datetimeTo: string,
limit: number
) {
'use server';
const url = new URL(import.meta.env.VITE_API_BASE_URL);
- url.pathname = `/v3/sensors/${sensorsId}/measurements`;
+ url.pathname = `/v3/sensors/${sensorsId}/${rollup}`;
url.search = `?datetime_from=${datetimeFrom.replace(
' ',
'%2b'
@@ -53,13 +54,14 @@ async function fetchSensorMeasurementsDownload(
async function fetchSensorMeasurements(
sensorsId: number,
+ rollup: string,
datetimeFrom: string,
datetimeTo: string,
- limit: number
+ limit?: number
) {
'use server';
const url = new URL(import.meta.env.VITE_API_BASE_URL);
- url.pathname = `/v3/sensors/${sensorsId}/hours`;
+ url.pathname = `/v3/sensors/${sensorsId}/${rollup}`;
url.search = `?datetime_from=${datetimeFrom.replace(
' ',
'%2b'
@@ -117,9 +119,12 @@ async function fetchProviders() {
return await res.json();
}
+type rollup = 'measurements' | 'hours' | 'days' | 'years';
+
export const getSensorMeasurements = GET(
async (
sensorsId: number,
+ rollup: rollup,
datetimeFrom: string,
datetimeTo: string,
limit: number = 1000
@@ -127,6 +132,7 @@ export const getSensorMeasurements = GET(
'use server';
const data = await fetchSensorMeasurements(
sensorsId,
+ rollup,
datetimeFrom,
datetimeTo,
limit
@@ -138,6 +144,7 @@ export const getSensorMeasurements = GET(
export const getSensorMeasurementsDownload = GET(
async (
sensorsId: number,
+ rollup: string,
datetimeFrom: string,
datetimeTo: string,
limit: number = 1000
@@ -145,6 +152,7 @@ export const getSensorMeasurementsDownload = GET(
'use server';
const data = await fetchSensorMeasurementsDownload(
sensorsId,
+ rollup,
datetimeFrom,
datetimeTo,
limit
diff --git a/src/components/DownloadCard/index.tsx b/src/components/DownloadCard/index.tsx
index 5b9a1cb..93d6b19 100644
--- a/src/components/DownloadCard/index.tsx
+++ b/src/components/DownloadCard/index.tsx
@@ -133,9 +133,10 @@ export function DownloadCard(props: Props) {
e.preventDefault();
setDownloading(true);
const formElements = e.target.elements;
- const tz = formElements[0].value;
- const dateFromValue = formElements[1].value;
- const dateToValue = formElements[2].value;
+ const rollup = formElements[0].value;
+ const tz = formElements[1].value;
+ const dateFromValue = formElements[2].value;
+ const dateToValue = formElements[3].value;
const sensorInputs = [...formElements]
.filter((o) => o.id.includes('checkbox-sensor'))
.filter((o) => o.checked);
@@ -143,15 +144,18 @@ export function DownloadCard(props: Props) {
Number(o.id.replace('checkbox-sensor-', ''))
);
let data = [];
+
for (const sensorId of sensorIds) {
const measurements = await getSensorMeasurementsDownload(
sensorId,
+ rollup,
dayjs(new Date(dateFromValue), props.timezone).toISOString(),
dayjs(new Date(dateToValue), props.timezone).toISOString()
);
data = data.concat(measurements);
await sleep(300);
}
+
const csvData = measurementsCsv(props, data);
downloadFile(`openaq_location_${props.id}_measurments.csv`, csvData);
setDownloading(false);
@@ -180,6 +184,13 @@ export function DownloadCard(props: Props) {
onFormSubmit(e);
}}
>
+
+