Comparing version 1.0.0 to 1.1.0
@@ -20,14 +20,14 @@ #!/usr/bin/env node | ||
try { | ||
const res = await get('https://www.cutters.no/wp-content/themes/cutters/sql/ventetid.php') | ||
const res = await get('https://www.cutters.no/api/salons') | ||
const salonsData = JSON.parse(res).data | ||
salonsData | ||
.sort((a, b) => a.ventetid - b.ventetid) | ||
.map(({ ventetid, venter, navn, sted }) => ({ | ||
ventetid: `${Math.round(ventetid / 60000)} min`, | ||
venter, | ||
navn, | ||
sted, | ||
.sort((a, b) => a.details.estimatedWait - b.details.estimatedWait) | ||
.map(({ name, postalPlace, details }) => ({ | ||
estimatedWait: `${Math.round(details.estimatedWait / 60000)} min`, | ||
numberOfWaiting: details.numberOfWaiting, | ||
name, | ||
postalPlace, | ||
})) | ||
.forEach(({ navn, sted, ventetid, venter }) => { | ||
console.log(`${navn.padEnd(30, ' ')}${sted.padEnd(14, ' ')}${ventetid}\t${venter} waiting`) | ||
.forEach(({ name, postalPlace, estimatedWait, numberOfWaiting }) => { | ||
console.log(`${name.padEnd(30, ' ')}${postalPlace.padEnd(14, ' ')}${estimatedWait}\t${numberOfWaiting} waiting`) | ||
}) | ||
@@ -34,0 +34,0 @@ } catch (error) { |
{ | ||
"name": "cutters", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Get Cutters salons sorted by wait time", | ||
@@ -5,0 +5,0 @@ "main": "cutters.js", |
@@ -1,2 +0,2 @@ | ||
# Cutters | ||
# Cutters :haircut: | ||
@@ -6,3 +6,3 @@ Get Cutters hair salons sorted by wait time in the terminal. | ||
``` | ||
~$ cutters | grep Oslo | head -3 | ||
$ npx cutters | grep Oslo | head -3 | ||
Oslo City Oslo 2 min 2 waiting | ||
@@ -31,1 +31,7 @@ Stortingsgata Oslo 8 min 1 waiting | ||
``` | ||
Need to follow how wait times are changing? | ||
``` | ||
watch -n 10 'cutters | grep Oslo | head -10' | ||
``` |
2204
36