Skip to content

Commit

Permalink
Portaventura fix 202107 (#340)
Browse files Browse the repository at this point in the history
* Fix Portaventura URL, still missing waiting time

* Improves code for PortAventura (#338)

* Parse PortAventura waiting time (approx)
  • Loading branch information
jeanmatthieud authored Jul 24, 2021
1 parent 18e0b8e commit 2559f14
Showing 1 changed file with 10 additions and 5 deletions.
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

0 comments on commit 2559f14

Please sign in to comment.