diff --git a/CHANGELOG.md b/CHANGELOG.md index 226bc8f7..d9cabeff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog Changes to adapters will be documented in this file. +## 11/22/2023 +### Set active: false +- south-australia-epa (needs fix, url won't resolve) ## 11/01/2023 ### DELETED diff --git a/src/adapters/buenos-aires.js b/src/adapters/buenos-aires.js index d5a3af51..80fb271a 100644 --- a/src/adapters/buenos-aires.js +++ b/src/adapters/buenos-aires.js @@ -29,7 +29,7 @@ export function fetchData(source, callback) { .map(function (i, el) { return { id: $(this).attr('value'), - name: $(this).text() + name: $(this).text(), }; }) .get(); @@ -48,12 +48,12 @@ export function fetchData(source, callback) { .map(function (i, el) { return { id: $(this).attr('value'), - name: $(this).text() + name: $(this).text(), }; }) .get(); - const today = DateTime.local().setZone(timezone).startOf('day'); + const today = DateTime.now().setZone(timezone).startOf('day'); stations.forEach((station) => { parameters.forEach((parameter) => { const url = makeStationQuery( @@ -75,10 +75,9 @@ export function fetchData(source, callback) { results = flattenDeep(results); results = convertUnits(results); - return callback(null, { name: 'unused', - measurements: results + measurements: results, }); }); }) @@ -151,7 +150,11 @@ const formatData = (body, station, parameter, today) => { const getDate = (today, hours) => { let date = DateTime.fromISO(today, { zone: timezone }); + // If hours are from 13 to 23, the date should be set to the day before yesterday if (hours >= 13 && hours <= 23) { + date = date.minus({ days: 2 }); + } else if (hours >= 0 && hours <= 12) { + // If hours are from 00 to 12, the date should be set to yesterday date = date.minus({ days: 1 }); } date = date.set({ hour: hours }); @@ -166,17 +169,17 @@ const getCoordinates = (station) => { case 'CENTENARIO': return { longitude: -58.43194, - latitude: -34.60638 + latitude: -34.60638, }; case 'CORDOBA': return { longitude: -58.39165, - latitude: -34.60441667 + latitude: -34.60441667, }; case 'LA BOCA': return { longitude: -58.36555, - latitude: -34.62527 + latitude: -34.62527, }; default: break; diff --git a/src/adapters/stateair.js b/src/adapters/stateair.js index 73476915..2406055c 100644 --- a/src/adapters/stateair.js +++ b/src/adapters/stateair.js @@ -1,8 +1,13 @@ +/** + * This code is responsible for implementing all methods related to fetching + * and returning data for the SateAir data sources. + */ + 'use strict'; import { convertUnits } from '../lib/utils.js'; - import client from '../lib/requests.js'; + import _ from 'lodash'; import { DateTime } from 'luxon'; import { load } from 'cheerio'; @@ -10,7 +15,7 @@ import { parallel } from 'async'; export const name = 'stateair'; -export async function fetchData (source, cb) { +export async function fetchData(source, cb) { // Generic fetch function const getData = async (url, done) => { try { @@ -121,7 +126,7 @@ const formatData = function (data) { case 'Kabul': return 'Asia/Kabul'; case 'Dharan': - return 'Asia/Aden'; + return 'Asia/Riyadh'; case 'Ashgabat': return 'Asia/Ashgabat'; case 'Guatemala City': @@ -147,14 +152,16 @@ const formatData = function (data) { return 'Africa/Accra'; } }; + const date = DateTime.fromFormat( dateString, 'yyyy-MM-dd HH:mm:ss', - getTZ(location) + { zone: getTZ(location) } ); + return { utc: date.toUTC().toISO({ suppressMilliseconds: true }), - local: date.toISO({ suppressMilliseconds: true }) + local: date.toISO({ suppressMilliseconds: true }), }; }; @@ -431,7 +438,7 @@ const formatData = function (data) { const location = $('channel').children('title').text().trim(); const baseObj = { location: 'US Diplomatic Post: ' + location, - parameter: parameter, + parameter, unit: parameter === 'pm25' ? 'µg/m³' : 'ppb', averagingPeriod: { value: 1, unit: 'hours' }, attribution: [ diff --git a/src/sources/au.json b/src/sources/au.json index 389be865..649aa94f 100644 --- a/src/sources/au.json +++ b/src/sources/au.json @@ -54,7 +54,7 @@ "info@openaq.org" ], "license": "Creative Commons Attribution 4.0 License. © Copyright 2023", - "active": true + "active": false }, { "url": "https://www.data.act.gov.au/api/id/94a5-zqnn.json",