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

Portaventura fix 202107 #340

Merged
merged 3 commits into from
Jul 24, 2021
Merged
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
15 changes: 10 additions & 5 deletions lib/portaventura/portaventura.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PortAventura extends Park {
constructor(options = {}) {
options.name = options.name || 'PortAventura';

// Europa-Park coordinates
// park's coordinates
options.latitude = options.latitude || 41.086456;
options.longitude = options.longitude || 1.153650;

Expand All @@ -46,14 +46,19 @@ class PortAventura extends Park {

FetchWaitTimes() {
return this.HTTP({
url: `${this[sApiBase]}ws/filters/${this[sParkTitle]}/atraccion/en`,
url: `${this[sApiBase]}ws/nv/filters/${this[sParkTitle]}/atraccion/en`,
}).then((rides) => {
rides.forEach((ride) => {
// parse wait time
const parsedTime = /([-\d]+)(?::(\d+))?/.exec(ride.tiempo_espera);
let waitTime = null;
if (parsedTime[1] !== '-1' && parsedTime[2] !== undefined) {
waitTime = (Number(parsedTime[1]) * 60) + Number(parsedTime[2]);
// TODO: find the location_status when a ride is not operational
if (ride.location_status === 0) {
waitTime = -1;
} else if (ride.time_range !== null) {
// time_range = "XX h" or "XX min" or null
// time_sign = "<" or ">" or null (not used)
const [value, unit] = ride.time_range.split(' ');
waitTime = parseInt(value, 10) * (unit === 'min' ? 1 : 60);
}

// update ride object
Expand Down