Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data sources and adapters #1069

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 11 additions & 8 deletions src/adapters/buenos-aires.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand All @@ -75,10 +75,9 @@ export function fetchData(source, callback) {

results = flattenDeep(results);
results = convertUnits(results);

return callback(null, {
name: 'unused',
measurements: results
measurements: results,
});
});
})
Expand Down Expand Up @@ -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 });
Expand All @@ -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;
Expand Down
19 changes: 13 additions & 6 deletions src/adapters/stateair.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/**
* 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';
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 {
Expand Down Expand Up @@ -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':
Expand All @@ -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 }),
};
};

Expand Down Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/sources/au.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"[email protected]"
],
"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",
Expand Down