Skip to content

Commit e631dec

Browse files
committed
chore: add script to generate regional sample data files
1 parent 2524898 commit e631dec

8 files changed

+4763
-750
lines changed

examples/generateRegionData.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
5+
const rawdata = fs.readFileSync('ikea-store-list.json');
6+
const data = JSON.parse(rawdata);
7+
8+
// eslint-disable-next-line prettier/prettier
9+
const regionLookup = { "AK": "West", "AL": "Southeast", "AR": "Southeast", "AZ": "Southwest", "CA": "West", "CO": "West", "CT": "Northeast", "DC": "Northeast", "DE": "Northeast", "FL": "Southeast", "GA": "Southeast", "HI": "West", "IA": "Midwest", "ID": "West", "IL": "Midwest", "IN": "Midwest", "KS": "Midwest", "KY": "Southeast", "LA": "Southeast", "MA": "Northeast", "MD": "Northeast", "ME": "Northeast", "MI": "Midwest", "MN": "Midwest", "MO": "Midwest", "MS": "Southeast", "MT": "West", "NC": "Southeast", "ND": "Midwest", "NE": "Midwest", "NH": "Northeast", "NJ": "Northeast", "NM": "Southwest", "NV": "West", "NY": "Northeast", "OH": "Midwest", "OK": "Southwest", "OR": "West", "PA": "Northeast", "RI": "Northeast", "SC": "Southeast", "SD": "Midwest", "TN": "Southeast", "TX": "Southwest", "UT": "West", "VA": "Southeast", "VT": "Northeast", "WA": "West", "WI": "Midwest", "WV": "Southeast", "WY": "West" };
10+
11+
/*
12+
{
13+
storeId: 50,
14+
storeCity: 'Renton',
15+
storeState: 'WA',
16+
storeAddress: '601 SW 41st St',
17+
storeZip: '98057',
18+
storeNumber: '488',
19+
storeURL:
20+
'https://www.ikea.com/us/en/stores/renton/?itm_campaign=lsf-mobile&itm_element=Button-LSP&itm_content=renton',
21+
offersURL:
22+
'https://www.ikea.com/us/en/stores/renton/?itm_campaign=lsf-mobile&itm_element=Button-LSP&itm_content=renton',
23+
geoURL:
24+
'https://www.google.com/maps/dir/Current+Location/601+SW+41st+St+Renton+WA+98057',
25+
geoLat: '47.4424256',
26+
geoLng: '-122.22569240000001',
27+
storeType: 'market'
28+
}
29+
*/
30+
31+
const mapLocations = data.reduce((p, v) => {
32+
const {
33+
geoLat,
34+
geoLng,
35+
storeId,
36+
storeCity,
37+
storeState,
38+
storeAddress,
39+
storeZip,
40+
storeNumber
41+
} = v;
42+
43+
const mapLocation = {
44+
externalId: storeNumber,
45+
title: storeAddress,
46+
location: {
47+
municipality: storeCity,
48+
region: storeState,
49+
country: 'USA',
50+
postalCode: storeZip,
51+
description: 'Nulla quis tortor orci. Etiam at risus et justo dignissim.',
52+
lat: geoLat,
53+
lng: geoLng
54+
},
55+
query:
56+
"FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
57+
entities: [
58+
{
59+
guid:
60+
Math.random() < 0.5
61+
? 'NjMwMDYwfE5SMXxXT1JLTE9BRHw1ODM'
62+
: 'NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI',
63+
entityType: 'WORKLOAD_ENTITY'
64+
}
65+
],
66+
contactEmail: '[email protected]',
67+
runbookUrl:
68+
'https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit'
69+
};
70+
71+
p.push(mapLocation);
72+
return p;
73+
}, []);
74+
// console.log(JSON.stringify(mapLocations, null, 2))
75+
76+
const byRegion = mapLocations.reduce((p, v) => {
77+
const state = v.location.region;
78+
const region = regionLookup[state];
79+
// console.log(region);
80+
81+
if (!p[region]) {
82+
p[region] = [];
83+
}
84+
85+
p[region].push(v);
86+
87+
return p;
88+
}, {});
89+
// console.log(JSON.stringify(byRegion, null, 2));
90+
91+
Object.entries(byRegion).forEach(([k, v]) => {
92+
const fileName = `sample-data-${k.toLowerCase()}.json`;
93+
const fileOutput = {
94+
items: v
95+
};
96+
const fileData = JSON.stringify(fileOutput, null, 2);
97+
fs.writeFileSync(fileName, fileData);
98+
});

examples/sample-data-midwest.json

+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
{
2+
"items": [
3+
{
4+
"externalId": "170",
5+
"title": "750 E Boughton Rd",
6+
"location": {
7+
"municipality": "Bolingbrook",
8+
"region": "IL",
9+
"country": "USA",
10+
"postalCode": "60440",
11+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
12+
"lat": "41.7279305",
13+
"lng": "-88.03783240000001"
14+
},
15+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
16+
"entities": [
17+
{
18+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
19+
"entityType": "WORKLOAD_ENTITY"
20+
}
21+
],
22+
"contactEmail": "[email protected]",
23+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
24+
},
25+
{
26+
"externalId": "210",
27+
"title": "1800 McConnor Pkwy",
28+
"location": {
29+
"municipality": "Schaumburg",
30+
"region": "IL",
31+
"country": "USA",
32+
"postalCode": "60173",
33+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
34+
"lat": "42.0568612",
35+
"lng": "-88.03617150000002"
36+
},
37+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
38+
"entities": [
39+
{
40+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
41+
"entityType": "WORKLOAD_ENTITY"
42+
}
43+
],
44+
"contactEmail": "[email protected]",
45+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
46+
},
47+
{
48+
"externalId": "536",
49+
"title": "11400 IKEA Way",
50+
"location": {
51+
"municipality": "Fishers",
52+
"region": "IN",
53+
"country": "USA",
54+
"postalCode": "32322",
55+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
56+
"lat": "39.954334",
57+
"lng": "-86.01207590000001"
58+
},
59+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
60+
"entities": [
61+
{
62+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHw1ODM",
63+
"entityType": "WORKLOAD_ENTITY"
64+
}
65+
],
66+
"contactEmail": "[email protected]",
67+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
68+
},
69+
{
70+
"externalId": "374",
71+
"title": "6000 Ikea Way",
72+
"location": {
73+
"municipality": "Merriam",
74+
"region": "KS",
75+
"country": "USA",
76+
"postalCode": "66202",
77+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
78+
"lat": "39.019697",
79+
"lng": "-94.69092409999996"
80+
},
81+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
82+
"entities": [
83+
{
84+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
85+
"entityType": "WORKLOAD_ENTITY"
86+
}
87+
],
88+
"contactEmail": "[email protected]",
89+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
90+
},
91+
{
92+
"externalId": "026",
93+
"title": "41640 Ford Rd",
94+
"location": {
95+
"municipality": "Canton",
96+
"region": "MI",
97+
"country": "USA",
98+
"postalCode": "48187",
99+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
100+
"lat": "42.324824",
101+
"lng": "-83.45166189999998"
102+
},
103+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
104+
"entities": [
105+
{
106+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
107+
"entityType": "WORKLOAD_ENTITY"
108+
}
109+
],
110+
"contactEmail": "[email protected]",
111+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
112+
},
113+
{
114+
"externalId": "212",
115+
"title": "8000 Ikea Way",
116+
"location": {
117+
"municipality": "Twin Cities",
118+
"region": "MN",
119+
"country": "USA",
120+
"postalCode": "55425",
121+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
122+
"lat": "44.8584007",
123+
"lng": "-93.24482769999997"
124+
},
125+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
126+
"entities": [
127+
{
128+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
129+
"entityType": "WORKLOAD_ENTITY"
130+
}
131+
],
132+
"contactEmail": "[email protected]",
133+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
134+
},
135+
{
136+
"externalId": "410",
137+
"title": "1 Ikea Way",
138+
"location": {
139+
"municipality": "St. Louis",
140+
"region": "MO",
141+
"country": "USA",
142+
"postalCode": "63112",
143+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
144+
"lat": "38.6331482",
145+
"lng": "-90.24403719999998"
146+
},
147+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
148+
"entities": [
149+
{
150+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHwzODI",
151+
"entityType": "WORKLOAD_ENTITY"
152+
}
153+
],
154+
"contactEmail": "[email protected]",
155+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
156+
},
157+
{
158+
"externalId": "511",
159+
"title": "1900 IKEA Way",
160+
"location": {
161+
"municipality": "Columbus",
162+
"region": "OH",
163+
"country": "USA",
164+
"postalCode": "43240",
165+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
166+
"lat": "40.1485005",
167+
"lng": "-82.96761170000002"
168+
},
169+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
170+
"entities": [
171+
{
172+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHw1ODM",
173+
"entityType": "WORKLOAD_ENTITY"
174+
}
175+
],
176+
"contactEmail": "[email protected]",
177+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
178+
},
179+
{
180+
"externalId": "175",
181+
"title": "9500 IKEA Way",
182+
"location": {
183+
"municipality": "West Chester",
184+
"region": "OH",
185+
"country": "USA",
186+
"postalCode": "45069",
187+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
188+
"lat": "39.3154678",
189+
"lng": "-84.43399769999996"
190+
},
191+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
192+
"entities": [
193+
{
194+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHw1ODM",
195+
"entityType": "WORKLOAD_ENTITY"
196+
}
197+
],
198+
"contactEmail": "[email protected]",
199+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
200+
},
201+
{
202+
"externalId": "560",
203+
"title": "7500 S. IKEA Way",
204+
"location": {
205+
"municipality": "Oak Creek",
206+
"region": "WI",
207+
"country": "USA",
208+
"postalCode": "53154",
209+
"description": "Nulla quis tortor orci. Etiam at risus et justo dignissim.",
210+
"lat": "42.88585",
211+
"lng": "-87.863136"
212+
},
213+
"query": "FROM Transaction SELECT average(duration) FACET entityGuid, appName WHERE entityGuid in ('NjMwMDYwfEFQTXxBUFBMSUNBVElPTnw2MDgwNzg2')",
214+
"entities": [
215+
{
216+
"guid": "NjMwMDYwfE5SMXxXT1JLTE9BRHw1ODM",
217+
"entityType": "WORKLOAD_ENTITY"
218+
}
219+
],
220+
"contactEmail": "[email protected]",
221+
"runbookUrl": "https://docs.google.com/document/d/1NOWVNqJ9G8Ks5jIf2HVRj2CLP0Mjui1FsaIqs7kXy-Y/edit"
222+
}
223+
]
224+
}

0 commit comments

Comments
 (0)