Mercurial > gemma
comparison client/src/store/fairwayavailability.js @ 3330:0e442b547f6d
mocking fairway_availability
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 20 May 2019 15:52:49 +0200 |
parents | 98ce6d101e01 |
children | 6172acfa7ff5 |
comparison
equal
deleted
inserted
replaced
3329:4a81accd6182 | 3330:0e442b547f6d |
---|---|
17 | 17 |
18 const FREQUENCIES = { | 18 const FREQUENCIES = { |
19 MONTHLY: "monthly", | 19 MONTHLY: "monthly", |
20 QUARTERLY: "quarterly", | 20 QUARTERLY: "quarterly", |
21 YEARLY: "yearly" | 21 YEARLY: "yearly" |
22 }; | |
23 | |
24 /** | |
25 * Maximum number of hours: | |
26 * Month: approx 744/720/672 hours for 31/30/21 days | |
27 * Quarter: aprrox 2160 per quarter (~90 days) | |
28 * Yearly: approx 8760 per year (~365 days) | |
29 */ | |
30 const MOCKDATA = { | |
31 [FREQUENCIES.MONTHLY]: ` | |
32 #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] | |
33 05-2018,670.000,450.000,70.000,50.000,100.000`, | |
34 // 06-2018,669.000,546.000,0.000,0.000,123.000 | |
35 // 07-2018,671.000,377.000,0.000,0.000,294.000 | |
36 // 08-2018,668.000,168.000,0.000,0.000,500.000 | |
37 // 09-2018,673.000,23.000,0.000,0.000,650.000 | |
38 // 10-2018,670.000,4.000,0.000,0.000,666.000 | |
39 // 11-2018,672.000,1.000,0.000,0.000,671.000 | |
40 // 12-2018,675.000,5.000,0.000,0.000,670.000 | |
41 // 01-2019,677.000,0.000,0.000,0.000,677.000 | |
42 // 02-2019,668.000,43.000,0.000,0.000,625.000 | |
43 // 03-2019,660.000,49.000,0.000,0.000,611.000 | |
44 // 04-2019,620.000,20.000,0.000,0.000,600.000 | |
45 // 05-2019,672.000,42.000,0.000,0.000,630.000`, | |
46 [FREQUENCIES.QUARTERLY]: ` | |
47 #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] | |
48 Q2-2018,1989.000,0.000,0.000,0.000,1823.000 | |
49 Q3-2018,2108.000,0.000,0.000,0.000,1956.000 | |
50 Q3-2018,2145.000,0.000,0.000,0.000,2001.000 | |
51 Q1-2019,2155.000,0.000,0.000,0.000,2021.000 | |
52 Q2-2019,2160.000,0.000,0.000,0.000,1998.000`, | |
53 [FREQUENCIES.YEARLY]: ` | |
54 #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] | |
55 2018,8360.000,0.000,0.000,0.000,7360.000 | |
56 2019,8153.000,0.000,0.000,0.000,7250.000` | |
22 }; | 57 }; |
23 | 58 |
24 const init = () => { | 59 const init = () => { |
25 return { | 60 return { |
26 type: "bottlenecks", | 61 type: "bottlenecks", |
82 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}`; | 117 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}`; |
83 HTTP.get(URL, { | 118 HTTP.get(URL, { |
84 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | 119 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
85 }) | 120 }) |
86 .then(response => { | 121 .then(response => { |
87 const { data } = response; | 122 //const { data } = response; |
123 const data = MOCKDATA[frequency]; | |
124 console.log(data); | |
88 const csv = data.split("\n").filter(x => x !== ""); //omit empty lines | 125 const csv = data.split("\n").filter(x => x !== ""); //omit empty lines |
89 commit("setLegend", csv.shift()); | 126 commit("setLegend", csv.shift()); |
90 let transformed = csv.map(e => { | 127 let transformed = csv.map(e => { |
91 const result = e.split(","); | 128 const result = e.split(","); |
92 const label = result.shift(); | 129 const label = result.shift(); |
93 const ldc = result.shift(); | 130 const ldc = result.shift(); |
94 const highestLevel = result.pop(); | 131 const highestLevel = result.pop(); |
132 let sum = 0; | |
133 const lowerLevels = result.map(x => { | |
134 const result = Number(x) + sum; | |
135 sum += Number(x); | |
136 return result; | |
137 }); | |
95 return { | 138 return { |
96 label: label, | 139 label: label, |
97 ldc: ldc, | 140 ldc: ldc, |
98 highestLevel: highestLevel, | 141 highestLevel: highestLevel, |
99 lowerLevels: result | 142 lowerLevels: lowerLevels |
100 }; | 143 }; |
101 }); | 144 }); |
102 commit("setFwData", transformed); | 145 commit("setFwData", transformed); |
103 resolve(response); | 146 resolve(response); |
104 }) | 147 }) |