|
|
@@ -18,9 +18,9 @@ const parser = new xml2js.Parser(/* options */);
|
|
18
|
18
|
|
|
19
|
19
|
@Injectable(IItemManager)
|
|
20
|
20
|
export class ItemManager
|
|
21
|
|
-implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefinitionExporter, IItemManager{
|
|
22
|
|
- name = "ItemManager" as "ItemManager";
|
|
23
|
|
-
|
|
|
21
|
+ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefinitionExporter, IItemManager {
|
|
|
22
|
+ name = "ItemManager" as "ItemManager";
|
|
|
23
|
+
|
|
24
|
24
|
@Inject(IAdmin)
|
|
25
|
25
|
private admin: IAdmin
|
|
26
|
26
|
|
|
|
@@ -52,16 +52,16 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
52
|
52
|
this.setPriority,
|
|
53
|
53
|
this.deletePriority
|
|
54
|
54
|
],
|
|
55
|
|
- },{
|
|
|
55
|
+ }, {
|
|
56
|
56
|
name: 'reset' as 'reset',
|
|
57
|
57
|
exportRPCs: () => [
|
|
58
|
58
|
this.wipeCurrencyAndItems
|
|
59
|
59
|
]
|
|
60
|
60
|
}]
|
|
61
|
61
|
|
|
62
|
|
- notifyRaid = async (raid:Raid | {id:number}) => {
|
|
|
62
|
+ notifyRaid = async (raid: Raid | { id: number }) => {
|
|
63
|
63
|
const data = await this.raidManager.getRaidData(<Raid>raid)
|
|
64
|
|
- this.pubsub.publish(""+raid.id, data)
|
|
|
64
|
+ this.pubsub.publish("" + raid.id, data)
|
|
65
|
65
|
await this.notifyRaids()
|
|
66
|
66
|
}
|
|
67
|
67
|
|
|
|
@@ -72,29 +72,30 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
72
|
72
|
wipeCurrencyAndItems = async () => {
|
|
73
|
73
|
await Promise.all([
|
|
74
|
74
|
this.userManager.wipeCurrency(),
|
|
75
|
|
- Promise.all(_Tiers.map(tier => this.admin.knex(tier+'tokens').where(true).del()))
|
|
|
75
|
+ Promise.all(_Tiers.map(tier => this.admin.knex(tier + 'tokens').where(true).del()))
|
|
76
|
76
|
])
|
|
77
|
77
|
}
|
|
78
|
78
|
|
|
79
|
|
- getItems = async () :Promise<Item[]> => await this.admin.knex.select('*').from('items')
|
|
|
79
|
+ getItems = async (): Promise<Item[]> => await this.admin.knex.select('*').from('items')
|
|
80
|
80
|
|
|
81
|
|
- getItem = async(name:string):Promise<Item> => {
|
|
82
|
|
- return await this.admin.knex('items').select('*').where('itemname','=',name).first()
|
|
|
81
|
+ getItem = async (name: string): Promise<Item> => {
|
|
|
82
|
+ return await this.admin.knex('items').select('*').where('itemname', '=', name).first()
|
|
83
|
83
|
}
|
|
84
|
84
|
|
|
85
|
|
- fetchItem = async (name:string):Promise<Item> => {
|
|
86
|
|
- const res = await fetch('https://classic.wowhead.com/item='+name+'&xml');
|
|
87
|
|
- const txt = await res.text();
|
|
88
|
|
- const r = await parser.parseStringPromise(txt);
|
|
|
85
|
+ fetchItem = async (name: string): Promise<Item> => {
|
|
|
86
|
+ const res = await fetch('https://classic.wowhead.com/item=' + name + '&xml');
|
|
|
87
|
+ const txt = await res.text();
|
|
|
88
|
+ const r = await parser.parseStringPromise(txt);
|
|
89
|
89
|
|
|
90
|
|
- try{
|
|
|
90
|
+ try {
|
|
91
|
91
|
return <Item>{
|
|
92
|
92
|
itemname: r.wowhead.item[0].name[0],
|
|
93
|
93
|
iconname: r.wowhead.item[0].icon[0]._,
|
|
94
|
94
|
url: r.wowhead.item[0].link[0],
|
|
95
|
95
|
quality: r.wowhead.item[0].quality[0]._,
|
|
96
|
|
- }
|
|
97
|
|
- }catch (e){
|
|
|
96
|
+ tooltip: r.wowhead.item[0].htmlTooltip[0]
|
|
|
97
|
+ }
|
|
|
98
|
+ } catch (e) {
|
|
98
|
99
|
console.log(name)
|
|
99
|
100
|
throw e
|
|
100
|
101
|
}
|
|
|
@@ -102,9 +103,9 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
102
|
103
|
|
|
103
|
104
|
getTableDefinitions(): TableDefiniton[] {
|
|
104
|
105
|
return [
|
|
105
|
|
- ...['null',..._Tiers].map(tier => {
|
|
|
106
|
+ ...['null', ..._Tiers].map(tier => {
|
|
106
|
107
|
return {
|
|
107
|
|
- name: tier+'tokens',
|
|
|
108
|
+ name: tier + 'tokens',
|
|
108
|
109
|
tableBuilder: (table) => {
|
|
109
|
110
|
table.primary(['characterid', 'itemname'])
|
|
110
|
111
|
table.integer("characterid")
|
|
|
@@ -116,7 +117,7 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
116
|
117
|
table.integer("level").defaultTo(1)
|
|
117
|
118
|
}
|
|
118
|
119
|
}
|
|
119
|
|
- }),{
|
|
|
120
|
+ }), {
|
|
120
|
121
|
name: 'priorities',
|
|
121
|
122
|
tableBuilder: (table) => {
|
|
122
|
123
|
table.increments('id').primary()
|
|
|
@@ -128,7 +129,7 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
128
|
129
|
table.integer('modifier')
|
|
129
|
130
|
table.string('description').nullable()
|
|
130
|
131
|
}
|
|
131
|
|
- },{
|
|
|
132
|
+ }, {
|
|
132
|
133
|
name: 'items',
|
|
133
|
134
|
tableBuilder: (table) => {
|
|
134
|
135
|
table.string('itemname').unique().notNullable().primary()
|
|
|
@@ -136,52 +137,53 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
136
|
137
|
table.string('url').notNullable()
|
|
137
|
138
|
table.string('quality').defaultTo('Epic').notNullable()
|
|
138
|
139
|
table.boolean('hidden').defaultTo(false).notNullable()
|
|
|
140
|
+ table.string('tooltip').notNullable()
|
|
139
|
141
|
table.enu('tier', _Tiers).notNullable()
|
|
140
|
142
|
}
|
|
141
|
143
|
}]
|
|
142
|
144
|
}
|
|
143
|
145
|
|
|
144
|
|
- buyToken = async (usertoken: string, charactername:string, itemname:string, signup: Signup): Promise<(SRToken & Character & Item) | undefined> => {
|
|
|
146
|
+ buyToken = async (usertoken: string, charactername: string, itemname: string, signup: Signup): Promise<(SRToken & Character & Item) | undefined> => {
|
|
145
|
147
|
const record = this.userManager.getUserRecordByToken(usertoken)
|
|
146
|
148
|
const character = await this.character.getCharacterByName(charactername)
|
|
147
|
149
|
|
|
148
|
|
- if(!record || !character || record.user.username !== character.username) return
|
|
149
|
|
-
|
|
|
150
|
+ if (!record || !character || record.user.username !== character.username) return
|
|
|
151
|
+
|
|
150
|
152
|
const item = await this.getItem(itemname)
|
|
151
|
|
- if(!item) return
|
|
|
153
|
+ if (!item) return
|
|
152
|
154
|
|
|
153
|
155
|
const currency = await this.userManager.getCurrency(record.user, item.tier)
|
|
154
|
|
- if(currency < 1) return
|
|
|
156
|
+ if (currency < 1) return
|
|
155
|
157
|
|
|
156
|
158
|
const streaks = await this.getTokens(character, [item.tier], false)
|
|
157
|
159
|
const activeTokens = await this.getTokens(character, [item.tier], true)
|
|
158
|
160
|
|
|
159
|
161
|
await this.userManager.decrementCurrency(record.user, item.tier, 1)
|
|
160
|
162
|
const modifier = await this.calculatePriorities(itemname, character)
|
|
161
|
|
-
|
|
|
163
|
+
|
|
162
|
164
|
const tx = await this.admin.knex.transaction()
|
|
163
|
165
|
|
|
164
|
|
- if(streaks.length > 0){
|
|
|
166
|
+ if (streaks.length > 0) {
|
|
165
|
167
|
const myStreak = streaks.find(token => token.itemname === itemname)
|
|
166
|
|
- if(myStreak){
|
|
|
168
|
+ if (myStreak) {
|
|
167
|
169
|
//getLogger('ItemManager').debug('update signupid and increment level')
|
|
168
|
170
|
await this.admin
|
|
169
|
|
- .knex(item.tier+'tokens')
|
|
170
|
|
- .transacting(tx)
|
|
171
|
|
- .where({
|
|
172
|
|
- characterid: character.id,
|
|
173
|
|
- itemname: item.itemname
|
|
174
|
|
- })
|
|
175
|
|
- .update({
|
|
176
|
|
- signupid: signup.id,
|
|
177
|
|
- level: myStreak.level+1
|
|
178
|
|
- })
|
|
|
171
|
+ .knex(item.tier + 'tokens')
|
|
|
172
|
+ .transacting(tx)
|
|
|
173
|
+ .where({
|
|
|
174
|
+ characterid: character.id,
|
|
|
175
|
+ itemname: item.itemname
|
|
|
176
|
+ })
|
|
|
177
|
+ .update({
|
|
|
178
|
+ signupid: signup.id,
|
|
|
179
|
+ level: myStreak.level + 1
|
|
|
180
|
+ })
|
|
179
|
181
|
|
|
180
|
182
|
}
|
|
181
|
183
|
|
|
182
|
184
|
//getLogger('ItemManager').debug('delete streaks')
|
|
183
|
185
|
await Promise.all(streaks.map(async s => await this.admin
|
|
184
|
|
- .knex(item.tier+'tokens')
|
|
|
186
|
+ .knex(item.tier + 'tokens')
|
|
185
|
187
|
.transacting(tx)
|
|
186
|
188
|
.where({
|
|
187
|
189
|
itemname: s.itemname,
|
|
|
@@ -191,179 +193,179 @@ implements FrontworkComponent<ItemManagerIfc, ItemManagerFeatureIfc>, TableDefin
|
|
191
|
193
|
.del()
|
|
192
|
194
|
))
|
|
193
|
195
|
|
|
194
|
|
- if(myStreak){
|
|
|
196
|
+ if (myStreak) {
|
|
195
|
197
|
await tx.commit()
|
|
196
|
|
- await this.notifyRaid({id: signup.raidid})
|
|
|
198
|
+ await this.notifyRaid({ id: signup.raidid })
|
|
197
|
199
|
|
|
198
|
200
|
return await this.getToken(character, item)
|
|
199
|
201
|
}
|
|
200
|
202
|
}
|
|
201
|
203
|
|
|
202
|
204
|
const matchingReserve = activeTokens.find(token => token.itemname === itemname)
|
|
203
|
|
- if(matchingReserve){
|
|
|
205
|
+ if (matchingReserve) {
|
|
204
|
206
|
//getLogger('ItemManager').debug('upgrade reserve')
|
|
205
|
207
|
await this.admin
|
|
206
|
|
- .knex(item.tier+'tokens')
|
|
207
|
|
- .transacting(tx)
|
|
208
|
|
- .increment('level')
|
|
209
|
|
- .where({
|
|
210
|
|
- signupid: signup.id,
|
|
211
|
|
- characterid: character.id,
|
|
212
|
|
- itemname: item.itemname
|
|
213
|
|
- })
|
|
214
|
|
- }else{
|
|
|
208
|
+ .knex(item.tier + 'tokens')
|
|
|
209
|
+ .transacting(tx)
|
|
|
210
|
+ .increment('level')
|
|
|
211
|
+ .where({
|
|
|
212
|
+ signupid: signup.id,
|
|
|
213
|
+ characterid: character.id,
|
|
|
214
|
+ itemname: item.itemname
|
|
|
215
|
+ })
|
|
|
216
|
+ } else {
|
|
215
|
217
|
//getLogger('ItemManager').debug('new reserve')
|
|
216
|
218
|
await this.admin
|
|
217
|
|
- .knex(item.tier+'tokens')
|
|
218
|
|
- .transacting(tx)
|
|
219
|
|
- .insert({
|
|
220
|
|
- characterid: character.id,
|
|
221
|
|
- itemname: item.itemname,
|
|
222
|
|
- level: 1+modifier,
|
|
223
|
|
- signupid: signup.id
|
|
224
|
|
- })
|
|
|
219
|
+ .knex(item.tier + 'tokens')
|
|
|
220
|
+ .transacting(tx)
|
|
|
221
|
+ .insert({
|
|
|
222
|
+ characterid: character.id,
|
|
|
223
|
+ itemname: item.itemname,
|
|
|
224
|
+ level: 1 + modifier,
|
|
|
225
|
+ signupid: signup.id
|
|
|
226
|
+ })
|
|
225
|
227
|
}
|
|
226
|
228
|
await tx.commit()
|
|
227
|
|
- await this.notifyRaid({id: signup.raidid})
|
|
|
229
|
+ await this.notifyRaid({ id: signup.raidid })
|
|
228
|
230
|
|
|
229
|
231
|
return await this.getToken(character, item)
|
|
230
|
232
|
}
|
|
231
|
233
|
|
|
232
|
|
- getAllPriorities = async() :Promise<(SRPriority & Spec & Item)[]> => this.admin
|
|
233
|
|
- .knex('priorities as p')
|
|
234
|
|
- .join('items as i', 'p.itemname', '=', 'i.itemname')
|
|
235
|
|
- .leftJoin('specs as s', 'p.specid', '=', 's.id')
|
|
236
|
|
- .select('*')
|
|
|
234
|
+ getAllPriorities = async (): Promise<(SRPriority & Spec & Item)[]> => this.admin
|
|
|
235
|
+ .knex('priorities as p')
|
|
|
236
|
+ .join('items as i', 'p.itemname', '=', 'i.itemname')
|
|
|
237
|
+ .leftJoin('specs as s', 'p.specid', '=', 's.id')
|
|
|
238
|
+ .select('*')
|
|
237
|
239
|
|
|
238
|
|
- deletePriority = async(priority:SRPriority) : Promise<void> => {
|
|
|
240
|
+ deletePriority = async (priority: SRPriority): Promise<void> => {
|
|
239
|
241
|
await this.admin.knex('priorities')
|
|
240
|
|
- .where(priority)
|
|
241
|
|
- .del()
|
|
|
242
|
+ .where(priority)
|
|
|
243
|
+ .del()
|
|
242
|
244
|
}
|
|
243
|
245
|
|
|
244
|
|
- setPriority = async(itemname:string, priority: SRPriority) : Promise<void> => {
|
|
|
246
|
+ setPriority = async (itemname: string, priority: SRPriority): Promise<void> => {
|
|
245
|
247
|
const item = await this.getItem(itemname)
|
|
246
|
|
-
|
|
|
248
|
+
|
|
247
|
249
|
await this.admin
|
|
248
|
|
- .knex('priorities')
|
|
249
|
|
- .insert(<SRPriority>{
|
|
250
|
|
- itemname: item.itemname,
|
|
251
|
|
- ...priority
|
|
252
|
|
- })
|
|
|
250
|
+ .knex('priorities')
|
|
|
251
|
+ .insert(<SRPriority>{
|
|
|
252
|
+ itemname: item.itemname,
|
|
|
253
|
+ ...priority
|
|
|
254
|
+ })
|
|
253
|
255
|
}
|
|
254
|
256
|
|
|
255
|
|
- getPriorities = async(itemname:string) : Promise<SRPriority[]> => {
|
|
|
257
|
+ getPriorities = async (itemname: string): Promise<SRPriority[]> => {
|
|
256
|
258
|
return await this.admin
|
|
257
|
|
- .knex('priorities as p')
|
|
258
|
|
- .where('p.itemname', '=', itemname)
|
|
259
|
|
- .select('*')
|
|
|
259
|
+ .knex('priorities as p')
|
|
|
260
|
+ .where('p.itemname', '=', itemname)
|
|
|
261
|
+ .select('*')
|
|
260
|
262
|
}
|
|
261
|
263
|
|
|
262
|
|
- calculatePriorities = async (itemname: string, character:Character):Promise<number>=> {
|
|
263
|
|
- const rules : SRPriority[] = await this.admin
|
|
264
|
|
- .knex('priorities as p')
|
|
265
|
|
- .select('*')
|
|
266
|
|
- .join('items as i', 'i.itemname', '=', 'p.itemname')
|
|
267
|
|
- .where('p.itemname', '=', itemname)
|
|
|
264
|
+ calculatePriorities = async (itemname: string, character: Character): Promise<number> => {
|
|
|
265
|
+ const rules: SRPriority[] = await this.admin
|
|
|
266
|
+ .knex('priorities as p')
|
|
|
267
|
+ .select('*')
|
|
|
268
|
+ .join('items as i', 'i.itemname', '=', 'p.itemname')
|
|
|
269
|
+ .where('p.itemname', '=', itemname)
|
|
268
|
270
|
|
|
269
|
271
|
return rules.map(rule => {
|
|
270
|
|
- if(rule.specid && rule.race){
|
|
271
|
|
- if(rule.specid === character.specid && rule.race === character.race)
|
|
|
272
|
+ if (rule.specid && rule.race) {
|
|
|
273
|
+ if (rule.specid === character.specid && rule.race === character.race)
|
|
272
|
274
|
return rule.modifier
|
|
273
|
275
|
else
|
|
274
|
276
|
return 0
|
|
275
|
277
|
}
|
|
276
|
278
|
|
|
277
|
|
- if(rule.specid){
|
|
278
|
|
- if(rule.specid === character.specid)
|
|
|
279
|
+ if (rule.specid) {
|
|
|
280
|
+ if (rule.specid === character.specid)
|
|
279
|
281
|
return rule.modifier
|
|
280
|
282
|
else
|
|
281
|
283
|
return 0
|
|
282
|
284
|
}
|
|
283
|
285
|
|
|
284
|
|
- if(rule.race){
|
|
285
|
|
- if(rule.race === character.race)
|
|
|
286
|
+ if (rule.race) {
|
|
|
287
|
+ if (rule.race === character.race)
|
|
286
|
288
|
return rule.modifier
|
|
287
|
289
|
else
|
|
288
|
290
|
return 0
|
|
289
|
291
|
}
|
|
290
|
292
|
return 0
|
|
291
|
|
- }).reduce((prev, curr) => prev+curr, 0)
|
|
|
293
|
+ }).reduce((prev, curr) => prev + curr, 0)
|
|
292
|
294
|
}
|
|
293
|
295
|
|
|
294
|
|
- getToken = async (character:Character, item:Item, valid=true): Promise<(SRToken & Character & Item) | undefined>=> {
|
|
|
296
|
+ getToken = async (character: Character, item: Item, valid = true): Promise<(SRToken & Character & Item) | undefined> => {
|
|
295
|
297
|
return await this.admin
|
|
296
|
|
- .knex(item.tier+'tokens as t')
|
|
297
|
|
- .select('*')
|
|
298
|
|
- .join('characters as c', 'c.id', '=', 't.characterid')
|
|
299
|
|
- .join('items as i', 'i.itemname', '=', 't.itemname')
|
|
300
|
|
- .where({
|
|
301
|
|
- characterid: character.id,
|
|
302
|
|
- "i.itemname": item.itemname
|
|
303
|
|
- })
|
|
304
|
|
- .andWhere(function(){
|
|
305
|
|
- if(valid){
|
|
306
|
|
- this.whereNotNull('t.signupid')
|
|
307
|
|
- }else{
|
|
308
|
|
- this.whereNull('t.signupid')
|
|
309
|
|
- }
|
|
310
|
|
- })
|
|
311
|
|
- .first()
|
|
312
|
|
- }
|
|
313
|
|
-
|
|
314
|
|
- getTokens = async (character:Character, tiers:Tiers[], valid=true) : Promise<(SRToken & Character & Item)[]> => {
|
|
315
|
|
- const ret = await Promise.all(tiers.map(async tier => {
|
|
316
|
|
- return await this.admin
|
|
317
|
|
- .knex(tier+'tokens as t')
|
|
|
298
|
+ .knex(item.tier + 'tokens as t')
|
|
318
|
299
|
.select('*')
|
|
319
|
300
|
.join('characters as c', 'c.id', '=', 't.characterid')
|
|
320
|
301
|
.join('items as i', 'i.itemname', '=', 't.itemname')
|
|
321
|
302
|
.where({
|
|
322
|
303
|
characterid: character.id,
|
|
|
304
|
+ "i.itemname": item.itemname
|
|
323
|
305
|
})
|
|
324
|
|
- .andWhere(function(){
|
|
325
|
|
- if(valid){
|
|
|
306
|
+ .andWhere(function () {
|
|
|
307
|
+ if (valid) {
|
|
326
|
308
|
this.whereNotNull('t.signupid')
|
|
327
|
|
- }else{
|
|
|
309
|
+ } else {
|
|
328
|
310
|
this.whereNull('t.signupid')
|
|
329
|
311
|
}
|
|
330
|
312
|
})
|
|
|
313
|
+ .first()
|
|
|
314
|
+ }
|
|
|
315
|
+
|
|
|
316
|
+ getTokens = async (character: Character, tiers: Tiers[], valid = true): Promise<(SRToken & Character & Item)[]> => {
|
|
|
317
|
+ const ret = await Promise.all(tiers.map(async tier => {
|
|
|
318
|
+ return await this.admin
|
|
|
319
|
+ .knex(tier + 'tokens as t')
|
|
|
320
|
+ .select('*')
|
|
|
321
|
+ .join('characters as c', 'c.id', '=', 't.characterid')
|
|
|
322
|
+ .join('items as i', 'i.itemname', '=', 't.itemname')
|
|
|
323
|
+ .where({
|
|
|
324
|
+ characterid: character.id,
|
|
|
325
|
+ })
|
|
|
326
|
+ .andWhere(function () {
|
|
|
327
|
+ if (valid) {
|
|
|
328
|
+ this.whereNotNull('t.signupid')
|
|
|
329
|
+ } else {
|
|
|
330
|
+ this.whereNull('t.signupid')
|
|
|
331
|
+ }
|
|
|
332
|
+ })
|
|
331
|
333
|
}))
|
|
332
|
334
|
return ret.flat()
|
|
333
|
335
|
}
|
|
334
|
336
|
|
|
335
|
|
- countItems = async() :Promise<number> => {
|
|
|
337
|
+ countItems = async (): Promise<number> => {
|
|
336
|
338
|
const count = await this.admin
|
|
337
|
|
- .knex('items')
|
|
338
|
|
- .count('*');
|
|
339
|
|
-
|
|
|
339
|
+ .knex('items')
|
|
|
340
|
+ .count('*');
|
|
|
341
|
+
|
|
340
|
342
|
return <number>count[0]['count(*)']
|
|
341
|
343
|
}
|
|
342
|
344
|
|
|
343
|
345
|
private initialized = false
|
|
344
|
346
|
initialize = async () => {
|
|
345
|
|
- if(this.initialized) return
|
|
346
|
|
- this.initialized = true
|
|
347
|
|
-
|
|
|
347
|
+ if (this.initialized) return
|
|
|
348
|
+ this.initialized = true
|
|
|
349
|
+
|
|
348
|
350
|
const itemTiers = allItems
|
|
349
|
351
|
|
|
350
|
352
|
const countCache = await this.countItems()
|
|
351
|
353
|
|
|
352
|
|
- if(countCache != Object.values(itemTiers).flat().length){
|
|
|
354
|
+ if (countCache != Object.values(itemTiers).flat().length) {
|
|
353
|
355
|
await Promise.all(
|
|
354
|
356
|
Object.entries(itemTiers)
|
|
355
|
|
- .map((kv) => Promise.all(
|
|
356
|
|
- kv[1].map(i => this.fetchItem(i)
|
|
357
|
|
- .then(item =>
|
|
358
|
|
- this.admin
|
|
359
|
|
- .knex('items')
|
|
360
|
|
- .insert({
|
|
361
|
|
- tier: kv[0],
|
|
362
|
|
- ...item
|
|
363
|
|
- }).catch(() => {})
|
|
|
357
|
+ .map((kv) => Promise.all(
|
|
|
358
|
+ kv[1].map(i => this.fetchItem(i)
|
|
|
359
|
+ .then(item =>
|
|
|
360
|
+ this.admin
|
|
|
361
|
+ .knex('items')
|
|
|
362
|
+ .insert({
|
|
|
363
|
+ tier: kv[0],
|
|
|
364
|
+ ...item
|
|
|
365
|
+ }).catch(() => { })
|
|
|
366
|
+ )
|
|
364
|
367
|
)
|
|
365
|
|
- )
|
|
366
|
|
- ))
|
|
|
368
|
+ ))
|
|
367
|
369
|
)
|
|
368
|
370
|
}
|
|
369
|
371
|
}
|