@@ -63,116 +63,189 @@ export class D2ApiAppSettings {
63
63
const compactValues = ( values : Maybe < string > [ ] ) => _ ( values ) . compact ( ) . value ( ) ;
64
64
65
65
return this . get ( ) . flatMap ( appSettings => {
66
- return apiToFuture (
67
- this . api . metadata . get ( {
68
- attributes : {
69
- fields : { id : true , name : true , code : true } ,
70
- filter : {
71
- identifiable : {
72
- in : compactValues ( [
73
- appSettings . dataSetFilterField ,
74
- appSettings . groupField ,
75
- appSettings . inputDateField ,
76
- appSettings . periodDateField ,
77
- appSettings . indicatorHideField ,
78
- // used for scripts to migrate data
79
- // not necessary to be configurable in the app through settings
80
- metadataCodes . attributes . outcomeDates ,
81
- metadataCodes . attributes . outputDates ,
82
- metadataCodes . attributes . project ,
83
- metadataCodes . attributes . outputCompanionIndicator ,
84
- metadataCodes . attributes . outcomeCompanionIndicator ,
85
- metadataCodes . attributes . indicatorMatching ,
86
- ] ) ,
87
- } ,
88
- } ,
89
- } ,
90
- categoryCombos : {
91
- fields : { id : true , name : true , code : true } ,
92
- filter : {
93
- identifiable : {
94
- in : compactValues ( [ appSettings . categoryComboId ] ) ,
95
- } ,
96
- } ,
97
- } ,
98
- organisationUnitLevels : {
99
- fields : { id : true , name : true , code : true , level : true } ,
100
- filter : {
101
- identifiable : { in : compactValues ( [ appSettings . countryLevelId ] ) } ,
102
- } ,
103
- } ,
104
- categories : {
105
- fields : { id : true , name : true , code : true } ,
106
- filter : {
107
- identifiable : {
108
- in : compactValues ( [ appSettings . defaultProjectId ] ) ,
109
- } ,
110
- } ,
111
- } ,
112
- dataElementGroupSets : {
113
- fields : { id : true , name : true , code : true } ,
114
- filter : {
115
- identifiable : {
116
- in : compactValues ( [
117
- appSettings . coreCompetencyId ,
118
- appSettings . dataElementThemeId ,
119
- appSettings . originDataElementId ,
120
- appSettings . statusDataElementId ,
121
- metadataCodes . dataElementGroupSets . measure ,
122
- ] ) ,
123
- } ,
124
- } ,
66
+ return (
67
+ Future . joinObj (
68
+ {
69
+ attributes : apiToFuture (
70
+ this . api . models . attributes . get ( {
71
+ fields : { id : true , name : true , code : true } ,
72
+ filter : {
73
+ id : {
74
+ in : compactValues ( [
75
+ appSettings . dataSetFilterField ,
76
+ appSettings . groupField ,
77
+ appSettings . inputDateField ,
78
+ appSettings . periodDateField ,
79
+ appSettings . indicatorHideField ,
80
+ ] ) ,
81
+ } ,
82
+ code : {
83
+ in : compactValues ( [
84
+ // used for scripts to migrate data
85
+ // not necessary to be configurable in the app through settings
86
+ metadataCodes . attributes . outcomeDates ,
87
+ metadataCodes . attributes . outputDates ,
88
+ metadataCodes . attributes . project ,
89
+ metadataCodes . attributes . outputCompanionIndicator ,
90
+ metadataCodes . attributes . outcomeCompanionIndicator ,
91
+ metadataCodes . attributes . indicatorMatching ,
92
+ ] ) ,
93
+ } ,
94
+ } ,
95
+ rootJunction : "OR" ,
96
+ paging : false ,
97
+ } )
98
+ ) ,
99
+ categoryCombos : apiToFuture (
100
+ this . api . models . categoryCombos . get ( {
101
+ fields : { id : true , name : true , code : true } ,
102
+ filter : {
103
+ id : {
104
+ in : compactValues ( [ appSettings . categoryComboId ] ) ,
105
+ } ,
106
+ } ,
107
+ paging : false ,
108
+ } )
109
+ ) ,
110
+ organizationUnitLevels : apiToFuture (
111
+ this . api . models . organisationUnitLevels . get ( {
112
+ fields : { id : true , name : true , code : true , level : true } ,
113
+ filter : {
114
+ id : { in : compactValues ( [ appSettings . countryLevelId ] ) } ,
115
+ } ,
116
+ paging : false ,
117
+ } )
118
+ ) ,
119
+ categories : apiToFuture (
120
+ this . api . models . categories . get ( {
121
+ fields : { id : true , name : true , code : true } ,
122
+ filter : {
123
+ id : {
124
+ in : compactValues ( [ appSettings . defaultProjectId ] ) ,
125
+ } ,
126
+ } ,
127
+ paging : false ,
128
+ } )
129
+ ) ,
130
+ dataElementGroupSets : apiToFuture (
131
+ this . api . models . dataElementGroupSets . get ( {
132
+ fields : { id : true , name : true , code : true } ,
133
+ filter : {
134
+ id : {
135
+ in : compactValues ( [
136
+ appSettings . coreCompetencyId ,
137
+ appSettings . dataElementThemeId ,
138
+ appSettings . originDataElementId ,
139
+ appSettings . statusDataElementId ,
140
+ ] ) ,
141
+ } ,
142
+ code : {
143
+ in : compactValues ( [
144
+ metadataCodes . dataElementGroupSets . measure ,
145
+ ] ) ,
146
+ } ,
147
+ } ,
148
+ rootJunction : "OR" ,
149
+ paging : false ,
150
+ } )
151
+ ) ,
152
+ dataElementGroups : apiToFuture (
153
+ this . api . models . dataElementGroups . get ( {
154
+ fields : { id : true , name : true , code : true } ,
155
+ filter : {
156
+ id : {
157
+ in : compactValues ( [
158
+ appSettings . mandatoryDataElementId ,
159
+ appSettings . outputId ,
160
+ appSettings . dataElementThemeId ,
161
+ ] ) ,
162
+ } ,
163
+ code : {
164
+ in : compactValues ( [
165
+ metadataCodes . dataElementGroups . localIndicator ,
166
+ metadataCodes . dataElementGroups . donorIndicator ,
167
+ metadataCodes . dataElementGroups . individualsIndicator ,
168
+ metadataCodes . dataElementGroups . householdsIndicator ,
169
+ ] ) ,
170
+ } ,
171
+ } ,
172
+ rootJunction : "OR" ,
173
+ paging : false ,
174
+ } )
175
+ ) ,
176
+ indicatorGroupSets : apiToFuture (
177
+ this . api . models . indicatorGroupSets . get ( {
178
+ fields : { id : true , name : true , code : true } ,
179
+ filter : {
180
+ id : {
181
+ in : compactValues ( [
182
+ appSettings . indicatorThemeId ,
183
+ appSettings . originIndicatorId ,
184
+ appSettings . statusIndicatorId ,
185
+ ] ) ,
186
+ } ,
187
+ } ,
188
+ paging : false ,
189
+ } )
190
+ ) ,
191
+ indicatorGroups : apiToFuture (
192
+ this . api . models . indicatorGroups . get ( {
193
+ fields : { id : true , name : true , code : true } ,
194
+ filter : {
195
+ id : {
196
+ in : compactValues ( [ appSettings . mandatoryIndicatorId ] ) ,
197
+ } ,
198
+ name : {
199
+ in : compactValues ( [
200
+ metadataCodes . indicatorGroup . donorIndicator ,
201
+ metadataCodes . indicatorGroup . localIndicator ,
202
+ ] ) ,
203
+ } ,
204
+ } ,
205
+ rootJunction : "OR" ,
206
+ paging : false ,
207
+ } )
208
+ ) ,
209
+ userGroups : apiToFuture (
210
+ this . api . models . userGroups . get ( {
211
+ fields : { id : true , name : true , code : true } ,
212
+ filter : {
213
+ code : { in : [ metadataCodes . userGroups . adminNotification ] } ,
214
+ } ,
215
+ paging : false ,
216
+ } )
217
+ ) ,
125
218
} ,
126
- dataElementGroups : {
127
- fields : { id : true , name : true , code : true } ,
128
- filter : {
129
- identifiable : {
130
- in : compactValues ( [
131
- appSettings . mandatoryDataElementId ,
132
- appSettings . outputId ,
133
- appSettings . dataElementThemeId ,
134
- metadataCodes . dataElementGroups . localIndicator ,
135
- metadataCodes . dataElementGroups . donorIndicator ,
136
- metadataCodes . dataElementGroups . individualsIndicator ,
137
- metadataCodes . dataElementGroups . householdsIndicator ,
138
- ] ) ,
219
+ { concurrency : 10 }
220
+ )
221
+ // .map(metadata => ({ appSettings, metadata }));
222
+ . map (
223
+ ( {
224
+ attributes,
225
+ categoryCombos,
226
+ organizationUnitLevels,
227
+ categories,
228
+ dataElementGroupSets,
229
+ dataElementGroups,
230
+ indicatorGroupSets,
231
+ indicatorGroups,
232
+ userGroups,
233
+ } ) => ( {
234
+ appSettings,
235
+ metadata : {
236
+ attributes : attributes . objects ,
237
+ categoryCombos : categoryCombos . objects ,
238
+ organisationUnitLevels : organizationUnitLevels . objects ,
239
+ categories : categories . objects ,
240
+ dataElementGroupSets : dataElementGroupSets . objects ,
241
+ dataElementGroups : dataElementGroups . objects ,
242
+ indicatorGroupSets : indicatorGroupSets . objects ,
243
+ indicatorGroups : indicatorGroups . objects ,
244
+ userGroups : userGroups . objects ,
139
245
} ,
140
- } ,
141
- } ,
142
- indicatorGroupSets : {
143
- fields : { id : true , name : true , code : true } ,
144
- filter : {
145
- identifiable : {
146
- in : compactValues ( [
147
- appSettings . indicatorThemeId ,
148
- appSettings . originIndicatorId ,
149
- appSettings . statusIndicatorId ,
150
- ] ) ,
151
- } ,
152
- } ,
153
- } ,
154
- indicatorGroups : {
155
- fields : { id : true , name : true , code : true } ,
156
- filter : {
157
- identifiable : {
158
- in : compactValues ( [
159
- appSettings . mandatoryIndicatorId ,
160
- metadataCodes . indicatorGroup . donorIndicator ,
161
- metadataCodes . indicatorGroup . localIndicator ,
162
- ] ) ,
163
- } ,
164
- } ,
165
- } ,
166
- userGroups : {
167
- fields : { id : true , name : true , code : true } ,
168
- filter : {
169
- identifiable : { in : [ metadataCodes . userGroups . adminNotification ] } ,
170
- } ,
171
- } ,
172
- } )
173
- ) . map ( metadata => {
174
- return { appSettings, metadata } ;
175
- } ) ;
246
+ } )
247
+ )
248
+ ) ;
176
249
} ) ;
177
250
}
178
251
0 commit comments