refactor part 1
This commit is contained in:
@@ -80,7 +80,7 @@ export async function queryHourly(start, end) {
|
||||
|
||||
export async function queryDaily(start, end) {
|
||||
const { c } = getClient()
|
||||
const measurements = ['environment', 'light', 'seismic', 'compass', 'ground', 'accumulation', 'lightning', 'gps']
|
||||
const measurements = ['environment', 'light', 'seismic', 'compass', 'accumulation', 'lightning', 'gps']
|
||||
const results = {}
|
||||
|
||||
for (const m of measurements) {
|
||||
@@ -119,12 +119,12 @@ export async function queryDaily(start, end) {
|
||||
for (const row of mins) {
|
||||
const time = truncateToDay(row._time)
|
||||
if (!results[time]) results[time] = { time }
|
||||
if (row.env_temp_c != null) results[time].env_temp_min_c = row.env_temp_c
|
||||
if (row.temperature != null) results[time].env_temp_min_c = row.temperature
|
||||
}
|
||||
for (const row of maxs) {
|
||||
const time = truncateToDay(row._time)
|
||||
if (!results[time]) results[time] = { time }
|
||||
if (row.env_temp_c != null) results[time].env_temp_max_c = row.env_temp_c
|
||||
if (row.temperature != null) results[time].env_temp_max_c = row.temperature
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ export async function getCoords() {
|
||||
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|
||||
`
|
||||
const rows = await query(flux)
|
||||
if (rows.length && rows[0].gps_lat && rows[0].gps_lon) {
|
||||
return { lat: rows[0].gps_lat, lon: rows[0].gps_lon, alt: rows[0].gps_alt_m || c.DEFAULT_ALT }
|
||||
if (rows.length && rows[0].latitude && rows[0].longitude) {
|
||||
return { lat: rows[0].latitude, lon: rows[0].longitude, alt: rows[0].altitude || c.ALTITUDE }
|
||||
}
|
||||
return { lat: c.DEFAULT_LAT, lon: c.DEFAULT_LON, alt: c.DEFAULT_ALT }
|
||||
return { lat: c.LATITUDE, lon: c.LONGITUDE, alt: c.ALTITUDE }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user