|
1 | 1 | with
|
2 | 2 | root := (select RootUser),
|
3 |
| - zones := array_agg(( |
| 3 | + zones := ( |
4 | 4 | for name in {
|
5 | 5 | "Americas, Pacific, Eurasia",
|
6 | 6 | "Africa",
|
7 |
| - "Not Specified", |
8 | 7 | "Asia"
|
9 | 8 | }
|
10 | 9 | union (
|
|
14 | 13 | director := root
|
15 | 14 | })
|
16 | 15 | )
|
17 |
| - )), |
| 16 | + ), |
| 17 | + new := (select zones filter .createdAt = datetime_of_statement()) |
| 18 | +select { `Added Field Zones` := new.name } |
| 19 | +filter count(new) > 0; |
| 20 | +with |
| 21 | + root := (select RootUser), |
18 | 22 | regions := (
|
19 |
| - for region in { |
20 |
| - ("Americas", zones[0]), |
21 |
| - ("Pacific", zones[0]), |
22 |
| - ("Eurasia", zones[0]), |
23 |
| - ("Africa - Southern", zones[1]), |
24 |
| - ("Africa - Anglophone East", zones[1]), |
25 |
| - ("Africa - Sahel", zones[1]), |
26 |
| - ("Africa - Congo Basin", zones[1]), |
27 |
| - ("Africa - Anglophone West", zones[1]), |
28 |
| - ("any", zones[2]), |
29 |
| - ("Asia - Islands", zones[3]), |
30 |
| - ("Asia - South", zones[3]), |
31 |
| - ("Asia - Mainland", zones[3]), |
| 23 | + for item in { |
| 24 | + (zone := "Americas, Pacific, Eurasia", regions := {"Americas", "Pacific", "Eurasia"}), |
| 25 | + (zone := "Africa", regions := { |
| 26 | + "Africa - Southern", |
| 27 | + "Africa - Anglophone East", |
| 28 | + "Africa - Sahel", |
| 29 | + "Africa - Congo Basin", |
| 30 | + "Africa - Anglophone West"}), |
| 31 | + (zone := "Asia", regions := {"Asia - Islands", "Asia - South", "Asia - Mainland"}) |
32 | 32 | }
|
33 | 33 | union (
|
34 |
| - (select FieldRegion filter .name = region.0) ?? |
35 |
| - (insert FieldRegion { |
36 |
| - name := region.0, |
37 |
| - fieldZone := region.1, |
38 |
| - director := root |
39 |
| - }) |
| 34 | + with zone := (select FieldZone filter .name = item.zone) |
| 35 | + select ( |
| 36 | + for region in item.regions |
| 37 | + union ( |
| 38 | + (select FieldRegion filter .name = region) ?? |
| 39 | + (insert FieldRegion { |
| 40 | + name := region, |
| 41 | + fieldZone := zone, |
| 42 | + director := root |
| 43 | + }) |
| 44 | + ) |
| 45 | + ) |
40 | 46 | )
|
41 |
| - ) |
42 |
| -select regions; |
| 47 | + ), |
| 48 | + new := (select regions filter .createdAt = datetime_of_statement()) |
| 49 | +select { `Added Field Regions` := new.name } |
| 50 | +filter count(new) > 0; |
0 commit comments