diff --git a/datasources/historical-prices.js b/datasources/historical-prices.js index 0cf011f9..fdb46003 100644 --- a/datasources/historical-prices.js +++ b/datasources/historical-prices.js @@ -1,6 +1,6 @@ -const WorkerKV = require('../utils/worker-kv'); +const WorkerKVSplit = require('../utils/worker-kv-split'); -class historicalPricesAPI extends WorkerKV { +class historicalPricesAPI extends WorkerKVSplit { constructor(dataSource) { super('historical_price_data', dataSource); this.defaultDays = 7; @@ -9,8 +9,9 @@ class historicalPricesAPI extends WorkerKV { } async getByItemId(context, itemId, days = this.defaultDays, halfResults = false) { - await this.init(context); - if (!this.cache) { + await this.init(context, itemId); + const data = await this.getKVData(context, itemId); + if (!data) { return Promise.reject(new Error('Historical prices cache is empty')); } @@ -22,7 +23,7 @@ class historicalPricesAPI extends WorkerKV { } } - let prices = this.cache.historicalPricePoint[itemId]; + let prices = data.historicalPricePoint[itemId]; if (!prices) { return []; } diff --git a/datasources/tasks.js b/datasources/tasks.js index 8e972a35..70fcb583 100644 --- a/datasources/tasks.js +++ b/datasources/tasks.js @@ -130,6 +130,22 @@ class TasksAPI extends WorkerKV { await this.init(context); return this.cache.QuestItem[id]; } + + async getAchievements(context) { + await this.init(context); + return this.cache.Achievement; + } + + async getAchievement(context, id) { + await this.init(context); + const achievements = await this.getAchievements(context); + for (const achievement of achievements) { + if (achievement.id === id) { + return achievement; + } + } + return Promise.reject(new Error(`No achievement with id ${id} found`)); + } } module.exports = TasksAPI; diff --git a/resolvers/taskResolver.js b/resolvers/taskResolver.js index 41e6def2..1594d4fe 100644 --- a/resolvers/taskResolver.js +++ b/resolvers/taskResolver.js @@ -1,5 +1,8 @@ module.exports = { Query: { + achievements(obj, args, context) { + return context.util.paginate(context.data.task.getAchievements(context), args); + }, async tasks(obj, args, context, info) { let tasks = await context.data.task.getList(context); if (args.faction) { @@ -22,6 +25,14 @@ module.exports = { return context.data.task.getQuestItems(context); } }, + Achievement: { + name(data, args, context, info) { + return context.data.task.getLocale(data.name, context, info); + }, + description(data, args, context, info) { + return context.data.task.getLocale(data.description, context, info); + }, + }, HealthEffect: { bodyParts(data, args, context, info) { if (data.bodyParts.length === 0) { @@ -193,6 +204,9 @@ module.exports = { item(data, args, context) { return context.data.item.getItem(context, data.item); }, + items(data, args, context) { + return data.items.map(id => context.data.item.getItem(context, id)); + }, maps(data, args, context) { return data.map_ids.map(id => { return context.data.map.get(context, id); diff --git a/schema.js b/schema.js index 6ba839d1..f4252295 100644 --- a/schema.js +++ b/schema.js @@ -1,4 +1,12 @@ module.exports = ` +type Achievement { + id: ID! + name: String! + description: String + hidden: Boolean! + playersCompletedPercent: Float! +} + type Ammo { item: Item! weight: Float! @@ -14,6 +22,7 @@ type Ammo { ricochetChance: Float! penetrationChance: Float! penetrationPower: Int! + penetrationPowerDeviation: Float accuracy: Int @deprecated(reason: "Use accuracyModifier instead.") accuracyModifier: Float recoil: Int @deprecated(reason: "Use recoilModifier instead.") @@ -347,6 +356,7 @@ type ItemPropertiesAmmo { ricochetChance: Float penetrationChance: Float penetrationPower: Int + penetrationPowerDeviation: Float accuracy: Int @deprecated(reason: "Use accuracyModifier instead.") accuracyModifier: Float recoil: Float @deprecated(reason: "Use recoilModifier instead.") @@ -385,6 +395,7 @@ type ItemPropertiesArmorAttachment { ergoPenalty: Int headZones: [String] material: ArmorMaterial + armorType: String blindnessProtection: Float bluntThroughput: Float slots: [ItemSlot] @@ -1050,6 +1061,7 @@ type TaskObjectiveItem implements TaskObjective { maps: [Map]! optional: Boolean! item: Item! + items: [Item]! count: Int! foundInRaid: Boolean! dogTagLevel: Int @@ -1306,6 +1318,7 @@ interface Vendor { #union Vendor = TraderOffer | FleaMarket type Query { + achievements(lang: LanguageCode, limit: Int, offset: Int): [Achievement]! ammo(lang: LanguageCode, limit: Int, offset: Int): [Ammo] #archivedItemPrices(id: ID!, limit: Int, offset: Int): [historicalPricePoint]! barters(lang: LanguageCode, limit: Int, offset: Int): [Barter]