From b80e2f2082402c3448f3f2afca4f97062493e95e Mon Sep 17 00:00:00 2001 From: GrantBirki Date: Mon, 16 Dec 2024 13:53:02 -0800 Subject: [PATCH 1/8] bump github/branch-deploy to `v10` --- .github/workflows/branch-deploy.yml | 2 +- .github/workflows/deploy.yml | 5 ++++- .github/workflows/unlock-on-merge.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/branch-deploy.yml b/.github/workflows/branch-deploy.yml index 87e2dae5..01564e7f 100644 --- a/.github/workflows/branch-deploy.yml +++ b/.github/workflows/branch-deploy.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: github/branch-deploy@v9 + - uses: github/branch-deploy@v10 id: branch-deploy with: admins: the-hideout/core-contributors diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25dd5041..855c92db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,11 +13,12 @@ jobs: runs-on: ubuntu-latest outputs: # set outputs for use in downstream jobs continue: ${{ steps.deployment-check.outputs.continue }} + sha: ${{ steps.deployment-check.outputs.sha }} steps: # https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md - name: deployment check - uses: github/branch-deploy@v9 + uses: github/branch-deploy@v10 id: deployment-check with: merge_deploy_mode: "true" @@ -32,6 +33,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + with: + ref: ${{ needs.deployment-check.outputs.sha }} - name: setup node uses: actions/setup-node@v4 diff --git a/.github/workflows/unlock-on-merge.yml b/.github/workflows/unlock-on-merge.yml index c12844d1..56a7c65e 100644 --- a/.github/workflows/unlock-on-merge.yml +++ b/.github/workflows/unlock-on-merge.yml @@ -16,7 +16,7 @@ jobs: steps: - name: unlock on merge - uses: github/branch-deploy@v9 + uses: github/branch-deploy@v10 id: unlock-on-merge with: unlock_on_merge_mode: "true" # <-- indicates that this is the "Unlock on Merge Mode" workflow From 2a96533c8787f533e260742d4e60c4845dea16ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 00:07:59 +0000 Subject: [PATCH 2/8] Bump github/branch-deploy from 9 to 10 in the github-actions group Bumps the github-actions group with 1 update: [github/branch-deploy](https://github.com/github/branch-deploy). Updates `github/branch-deploy` from 9 to 10 - [Release notes](https://github.com/github/branch-deploy/releases) - [Commits](https://github.com/github/branch-deploy/compare/v9...v10) --- updated-dependencies: - dependency-name: github/branch-deploy dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/branch-deploy.yml | 2 +- .github/workflows/deploy.yml | 2 +- .github/workflows/unlock-on-merge.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/branch-deploy.yml b/.github/workflows/branch-deploy.yml index 87e2dae5..01564e7f 100644 --- a/.github/workflows/branch-deploy.yml +++ b/.github/workflows/branch-deploy.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: github/branch-deploy@v9 + - uses: github/branch-deploy@v10 id: branch-deploy with: admins: the-hideout/core-contributors diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25dd5041..29c800fb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,7 +17,7 @@ jobs: steps: # https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md - name: deployment check - uses: github/branch-deploy@v9 + uses: github/branch-deploy@v10 id: deployment-check with: merge_deploy_mode: "true" diff --git a/.github/workflows/unlock-on-merge.yml b/.github/workflows/unlock-on-merge.yml index c12844d1..56a7c65e 100644 --- a/.github/workflows/unlock-on-merge.yml +++ b/.github/workflows/unlock-on-merge.yml @@ -16,7 +16,7 @@ jobs: steps: - name: unlock on merge - uses: github/branch-deploy@v9 + uses: github/branch-deploy@v10 id: unlock-on-merge with: unlock_on_merge_mode: "true" # <-- indicates that this is the "Unlock on Merge Mode" workflow From eee00951d05eceb6ded1f916687f877320e807e4 Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 1 Jan 2025 17:11:44 -0600 Subject: [PATCH 3/8] split info into handbook kv --- datasources/handbook.mjs | 90 +++++++++++++++++++++++++++++++++++ datasources/index.mjs | 2 + datasources/items.mjs | 89 +--------------------------------- resolvers/hideoutResolver.mjs | 2 +- resolvers/itemResolver.mjs | 62 ++++++++++++++---------- resolvers/taskResolver.mjs | 4 +- schema-static.mjs | 1 + 7 files changed, 134 insertions(+), 116 deletions(-) create mode 100644 datasources/handbook.mjs diff --git a/datasources/handbook.mjs b/datasources/handbook.mjs new file mode 100644 index 00000000..3cc184a3 --- /dev/null +++ b/datasources/handbook.mjs @@ -0,0 +1,90 @@ +import WorkerKV from '../utils/worker-kv.mjs'; + +class HandbookAPI extends WorkerKV { + constructor(dataSource) { + super('handbook_data', dataSource); + //this.gameModes.push('pve'); + } + + async getCategory(context, info, id) { + const { cache } = await this.getCache(context, info); + return cache.ItemCategory[id] || cache.HandbookCategory[id]; + } + + async getTopCategory(context, info, id) { + const cat = await this.getCategory(context, info, id); + if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id); + return cat; + } + + async getCategories(context, info) { + const { cache } = await this.getCache(context, info); + if (!cache) { + return Promise.reject(new Error('Item cache is empty')); + } + const categories = []; + for (const id in cache.ItemCategory) { + categories.push(cache.ItemCategory[id]); + } + return categories; + } + + async getCategoriesEnum(context, info) { + const cats = await this.getCategories(context, info); + const map = {}; + for (const id in cats) { + map[cats[id].enumName] = cats[id]; + } + return map; + } + + async getHandbookCategory(context, info, id) { + const { cache } = await this.getCache(context, info); + return cache.HandbookCategory[id]; + } + + async getHandbookCategories(context, info) { + const { cache } = await this.getCache(context, info); + if (!cache) { + return Promise.reject(new Error('Item cache is empty')); + } + return Object.values(cache.HandbookCategory); + } + + async getArmorMaterials(context, info) { + const { cache } = await this.getCache(context, info); + return Object.values(cache.ArmorMaterial).sort(); + } + + async getArmorMaterial(context, info, matKey) { + const { cache } = await this.getCache(context, info); + return cache.ArmorMaterial[matKey]; + } + + async getMasterings(context, info) { + const { cache } = await this.getCache(context, info); + return cache.Mastering; + } + + async getMastering(context, info, mastId) { + const { cache } = await this.getCache(context, info); + return cache.Mastering.find(m => m.id === mastId); + } + + async getSkills(context, info) { + const { cache } = await this.getCache(context, info); + return cache.Skill; + } + + async getSkill(context, info, skillId) { + const { cache } = await this.getCache(context, info); + return cache.Skill.find(s => s.id === skillId); + } + + async getPlayerLevels(context, info) { + const { cache } = await this.getCache(context, info); + return cache.PlayerLevel; + } +} + +export default HandbookAPI; diff --git a/datasources/index.mjs b/datasources/index.mjs index 3a7886d9..0b236f36 100644 --- a/datasources/index.mjs +++ b/datasources/index.mjs @@ -1,5 +1,6 @@ import BartersAPI from './barters.mjs'; import CraftsAPI from './crafts.mjs'; +import HandbookAPI from './handbook.mjs'; import HideoutAPI from './hideout.mjs'; import HistoricalPricesAPI from './historical-prices.mjs'; import ArchivedPricesAPI from './archived-prices.mjs'; @@ -23,6 +24,7 @@ class DataSource { this.worker = { barter: new BartersAPI(this), craft: new CraftsAPI(this), + handbook: new HandbookAPI(this), hideout: new HideoutAPI(this), historicalPrice: new HistoricalPricesAPI(this), archivedPrice: new ArchivedPricesAPI(this), diff --git a/datasources/items.mjs b/datasources/items.mjs index aa6522d8..d8554e1c 100644 --- a/datasources/items.mjs +++ b/datasources/items.mjs @@ -170,7 +170,7 @@ class ItemsAPI extends WorkerKV { if (!items) { items = Object.values(cache.Item); } - const categories = (await this.getCategories(context, info)).filter(cat => names.includes(cat.enumName)); + const categories = (await context.data.worker.handbook.getCategories(context, info)).filter(cat => names.includes(cat.enumName)); return items.filter((item) => { return item.categories.some(catId => categories.some(cat => cat.id === catId)); }); @@ -181,7 +181,7 @@ class ItemsAPI extends WorkerKV { if (!items) { items = Object.values(cache.Item); } - const categories = (await this.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName)); + const categories = (await context.data.worker.handbook.getHandbookCategories(context, info)).filter(cat => names.includes(cat.enumName)); return items.filter((item) => { return item.handbookCategories.some(catId => categories.some(cat => cat.id === catId)); }); @@ -216,86 +216,11 @@ class ItemsAPI extends WorkerKV { }); } - async getCategory(context, info, id) { - const { cache } = await this.getCache(context, info); - return cache.ItemCategory[id] || cache.HandbookCategory[id]; - } - - async getTopCategory(context, info, id) { - const cat = await this.getCategory(context, info, id); - if (cat && cat.parent_id) return this.getTopCategory(context, info, cat.parent_id); - return cat; - } - - async getCategories(context, info) { - const { cache } = await this.getCache(context, info); - if (!cache) { - return Promise.reject(new Error('Item cache is empty')); - } - const categories = []; - for (const id in cache.ItemCategory) { - categories.push(cache.ItemCategory[id]); - } - return categories; - } - - async getCategoriesEnum(context, info) { - const cats = await this.getCategories(context, info); - const map = {}; - for (const id in cats) { - map[cats[id].enumName] = cats[id]; - } - return map; - } - - async getHandbookCategory(context, info, id) { - const { cache } = await this.getCache(context, info); - return cache.HandbookCategory[id]; - } - - async getHandbookCategories(context, info) { - const { cache } = await this.getCache(context, info); - if (!cache) { - return Promise.reject(new Error('Item cache is empty')); - } - return Object.values(cache.HandbookCategory); - } - async getFleaMarket(context, info) { const { cache } = await this.getCache(context, info); return cache.FleaMarket; } - async getArmorMaterials(context, info) { - const { cache } = await this.getCache(context, info); - return Object.values(cache.ArmorMaterial).sort(); - } - - async getArmorMaterial(context, info, matKey) { - const { cache } = await this.getCache(context, info); - return cache.ArmorMaterial[matKey]; - } - - async getMasterings(context, info) { - const { cache } = await this.getCache(context, info); - return cache.Mastering; - } - - async getMastering(context, info, mastId) { - const { cache } = await this.getCache(context, info); - return cache.Mastering.find(m => m.id === mastId); - } - - async getSkills(context, info) { - const { cache } = await this.getCache(context, info); - return cache.Skill; - } - - async getSkill(context, info, skillId) { - const { cache } = await this.getCache(context, info); - return cache.Skill.find(s => s.id === skillId); - } - async getAmmoList(context, info) { const allAmmo = await this.getItemsByBsgCategoryId(context, info, '5485a8684bdc2da71d8b4567').then(ammoItems => { // ignore bb @@ -308,16 +233,6 @@ class ItemsAPI extends WorkerKV { }; }); } - - async getPlayerLevels(context, info) { - const { cache } = await this.getCache(context, info); - return cache.PlayerLevel; - } - - async getTypes(context, info) { - const { cache } = await this.getCache(context, info); - return cache.ItemType; - } } export default ItemsAPI; diff --git a/resolvers/hideoutResolver.mjs b/resolvers/hideoutResolver.mjs index 7fc0429b..f5c65589 100644 --- a/resolvers/hideoutResolver.mjs +++ b/resolvers/hideoutResolver.mjs @@ -50,7 +50,7 @@ export default { return context.data.worker.hideout.getLocale(data.name, context, info); }, skill(data, args, context, info) { - return context.data.worker.item.getSkill(context, info, data.name); + return context.data.worker.handbook.getSkill(context, info, data.name); }, }, HideoutModule: { diff --git a/resolvers/itemResolver.mjs b/resolvers/itemResolver.mjs index dcc6c900..e1123d6f 100644 --- a/resolvers/itemResolver.mjs +++ b/resolvers/itemResolver.mjs @@ -53,10 +53,10 @@ export default { return context.util.paginate(items, args); }, itemCategories(obj, args, context, info) { - return context.util.paginate(context.data.worker.item.getCategories(context, info), args); + return context.util.paginate(context.data.worker.handbook.getCategories(context, info), args); }, handbookCategories(obj, args, context, info) { - return context.util.paginate(context.data.worker.item.getHandbookCategories(context, info), args); + return context.util.paginate(context.data.worker.handbook.getHandbookCategories(context, info), args); }, itemsByIDs(obj, args, context, info) { return context.data.worker.item.getItemsByIDs(context, info, args.ids, false); @@ -73,6 +73,16 @@ export default { itemsByBsgCategoryId(obj, args, context, info) { return context.data.worker.item.getItemsByBsgCategoryId(context, info, args.bsgCategoryId); }, + async itemPrices(obj, args, context, info) { + const [ + historical, + archived, + ] = await Promise.all([ + context.data.worker.historicalPrice.getByItemId(context, info, args.id, 30), + context.data.worker.archivedPrice.getByItemId(context, info, args.id), + ]); + return context.util.paginate([...archived, ...historical], args); + }, historicalItemPrices(obj, args, context, info) { return context.util.paginate(context.data.worker.historicalPrice.getByItemId(context, info, args.id, args.days), args); }, @@ -80,19 +90,19 @@ export default { return context.util.paginate(context.data.worker.archivedPrice.getByItemId(context, info, args.id), args); }, armorMaterials(obj, args, context, info) { - return context.data.worker.item.getArmorMaterials(context, info); + return context.data.worker.handbook.getArmorMaterials(context, info); }, fleaMarket(obj, args, context, info) { return context.data.worker.item.getFleaMarket(context, info); }, mastering(obj, args, context, info) { - return context.data.worker.item.getMasterings(context, info); + return context.data.worker.handbook.getMasterings(context, info); }, playerLevels(obj, args, context, info) { - return context.data.worker.item.getPlayerLevels(context, info); + return context.data.worker.handbook.getPlayerLevels(context, info); }, skills(obj, args, context, info) { - return context.data.worker.item.getSkills(context, info); + return context.data.worker.handbook.getSkills(context, info); }, }, Item: { @@ -113,25 +123,25 @@ export default { ]; }, bsgCategory(data, args, context, info) { - if (data.bsgCategoryId) return context.data.worker.item.getCategory(context, info, data.bsgCategoryId); + if (data.bsgCategoryId) return context.data.worker.handbook.getCategory(context, info, data.bsgCategoryId); return null; }, category(data, args, context, info) { - if (data.bsgCategoryId) return context.data.worker.item.getCategory(context, info, data.bsgCategoryId); + if (data.bsgCategoryId) return context.data.worker.handbook.getCategory(context, info, data.bsgCategoryId); return null; }, categoryTop(data, args, context, info) { - if (data.bsgCategoryId) return context.data.worker.item.getTopCategory(context, info, data.bsgCategoryId); + if (data.bsgCategoryId) return context.data.worker.handbook.getTopCategory(context, info, data.bsgCategoryId); return null; }, categories(data, args, context, info) { return data.categories.map(id => { - return context.data.worker.item.getCategory(context, info, id); + return context.data.worker.handbook.getCategory(context, info, id); }); }, handbookCategories(data, args, context, info) { return data.handbookCategories.map(id => { - return context.data.worker.item.getCategory(context, info, id); + return context.data.worker.handbook.getCategory(context, info, id); }); }, async conflictingItems(data, args, context, info) { @@ -232,7 +242,7 @@ export default { return context.data.worker.item.getLocale(data.zones, context, info); }, material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, }, ItemArmorSlotOpen: { @@ -259,25 +269,25 @@ export default { }, ItemCategory: { name(data, args, context, info) { - return context.data.worker.item.getLocale(data.name, context, info); + return context.data.worker.handbook.getLocale(data.name, context, info); }, parent(data, args, context, info) { - if (data.parent_id) return context.data.worker.item.getCategory(context, info, data.parent_id); + if (data.parent_id) return context.data.worker.handbook.getCategory(context, info, data.parent_id); return null; }, children(data, args, context, info) { - return data.child_ids.map(id => context.data.worker.item.getCategory(context, info, id)); + return data.child_ids.map(id => context.data.worker.handbook.getCategory(context, info, id)); } }, ItemFilters: { allowedCategories(data, args, context, info) { - return data.allowedCategories.map(id => context.data.worker.item.getCategory(context, info, id)); + return data.allowedCategories.map(id => context.data.worker.handbook.getCategory(context, info, id)); }, allowedItems(data, args, context, info) { return data.allowedItems.map(id => context.data.worker.item.getItem(context, info, id)); }, excludedCategories(data, args, context, info) { - return data.excludedCategories.map(id => context.data.worker.item.getCategory(context, info, id)); + return data.excludedCategories.map(id => context.data.worker.handbook.getCategory(context, info, id)); }, excludedItems(data, args, context, info) { return data.excludedItems.map(id => context.data.worker.item.getItem(context, info, id)); @@ -299,7 +309,7 @@ export default { return context.data.worker.item.getLocale(data.armorType, context, info); }, material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, zones(data, args, context, info) { return context.data.worker.item.getLocale(data.zones, context, info); @@ -307,7 +317,7 @@ export default { }, ItemPropertiesArmorAttachment: { material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, headZones(data, args, context, info) { return context.data.worker.item.getLocale(data.headZones, context, info); @@ -326,7 +336,7 @@ export default { return context.data.worker.item.getLocale(data.armorType, context, info); }, material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, zones(data, args, context, info) { return context.data.worker.item.getLocale(data.zones, context, info); @@ -337,7 +347,7 @@ export default { }, ItemPropertiesGlasses: { material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, }, ItemPropertiesHelmet: { @@ -345,7 +355,7 @@ export default { return context.data.worker.item.getLocale(data.armorType, context, info); }, material(data, args, context, info) { - return context.data.worker.item.getArmorMaterial(context, info, data.armor_material_id); + return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, headZones(data, args, context, info) { return context.data.worker.item.getLocale(data.headZones, context, info); @@ -396,7 +406,7 @@ export default { }, ArmorMaterial: { name(data, args, context, info) { - return context.data.worker.item.getLocale(data.name, context, info); + return context.data.worker.handbook.getLocale(data.name, context, info); } }, FleaMarket: { @@ -419,7 +429,7 @@ export default { }, Skill: { name(data, args, context, info) { - return context.data.worker.item.getLocale(data.name, context, info); + return context.data.worker.handbook.getLocale(data.name, context, info); } }, StimEffect: { @@ -427,10 +437,10 @@ export default { return context.data.worker.item.getLocale(data.type, context, info); }, skill(data, args, context, info) { - return context.data.worker.item.getSkill(context, info, data.skillName); + return context.data.worker.handbook.getSkill(context, info, data.skillName); }, skillName(data, args, context, info) { - return context.data.worker.item.getLocale(data.skillName, context, info); + return context.data.worker.handbook.getLocale(data.skillName, context, info); } }, Vendor: { diff --git a/resolvers/taskResolver.mjs b/resolvers/taskResolver.mjs index 11428097..ca9bedee 100644 --- a/resolvers/taskResolver.mjs +++ b/resolvers/taskResolver.mjs @@ -61,7 +61,7 @@ export default { }, SkillLevel: { skill(data, args, context, info) { - return context.data.worker.item.getSkill(context, info, data.name); + return context.data.worker.handbook.getSkill(context, info, data.name); }, name(data, args, context, info) { return context.data.worker.task.getLocale(data.name, context, info); @@ -155,7 +155,7 @@ export default { }, containsCategory(data, args, context, info) { return data.containsCategory.map((cat) => { - return context.data.worker.item.getCategory(context, info, cat.id); + return context.data.worker.handbook.getCategory(context, info, cat.id); }); }, containsOne(data, args, context, info) { diff --git a/schema-static.mjs b/schema-static.mjs index ba3e4def..79495359 100644 --- a/schema-static.mjs +++ b/schema-static.mjs @@ -1383,6 +1383,7 @@ type Query { historicalItemPrices(id: ID!, days: Int, lang: LanguageCode, gameMode: GameMode, limit: Int, offset: Int): [historicalPricePoint]! item(id: ID, normalizedName: String, lang: LanguageCode, gameMode: GameMode): Item items(ids: [ID], name: String, names: [String], type: ItemType, types: [ItemType], categoryNames: [ItemCategoryName], handbookCategoryNames: [HandbookCategoryName] bsgCategoryId: String, bsgCategoryIds: [String], bsgCategory: String, lang: LanguageCode, gameMode: GameMode, limit: Int, offset: Int): [Item]! + itemPrices(id: ID!, limit: Int, offset: Int): [historicalPricePoint]! itemCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]! goonReports(lang: LanguageCode, gameMode: GameMode, limit: Int, ofset: Int): [GoonReport]! handbookCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]! From b512c785a13634efb57936c2cea4e1e68b160b24 Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 1 Jan 2025 17:19:39 -0600 Subject: [PATCH 4/8] update test --- script/ci/Tarkov.dev.postman_collection.json | 1 - 1 file changed, 1 deletion(-) diff --git a/script/ci/Tarkov.dev.postman_collection.json b/script/ci/Tarkov.dev.postman_collection.json index 869b976b..03fb77ce 100644 --- a/script/ci/Tarkov.dev.postman_collection.json +++ b/script/ci/Tarkov.dev.postman_collection.json @@ -515,7 +515,6 @@ "\r", "pm.test(\"Has correct data\", function () {\r", " pm.expect(pm.response.json().data.historicalItemPrices).to.be.a(\"array\");\r", - " pm.expect(pm.response.json().data.historicalItemPrices.length).to.be.above(0);\r", "});\r", "\r", "pm.test(\"No errors\", function () {\r", From 2be6381ea9ce7ea0fd5b867ac3031a8b8b528ccd Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Fri, 3 Jan 2025 14:52:50 -0600 Subject: [PATCH 5/8] move item properties to handbook --- datasources/handbook.mjs | 5 +++++ resolvers/itemResolver.mjs | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/datasources/handbook.mjs b/datasources/handbook.mjs index 3cc184a3..4d61d10f 100644 --- a/datasources/handbook.mjs +++ b/datasources/handbook.mjs @@ -85,6 +85,11 @@ class HandbookAPI extends WorkerKV { const { cache } = await this.getCache(context, info); return cache.PlayerLevel; } + + async getItemProperties(context, info, itemId) { + const { cache } = await this.getCache(context, info); + return cache.ItemProperties[itemId]; + } } export default HandbookAPI; diff --git a/resolvers/itemResolver.mjs b/resolvers/itemResolver.mjs index e1123d6f..26468717 100644 --- a/resolvers/itemResolver.mjs +++ b/resolvers/itemResolver.mjs @@ -225,6 +225,9 @@ export default { }, imageLinkFallback(data) { return data.inspectImageLink; + }, + properties(data, args, context, info) { + return context.data.worker.handbook.getItemProperties(context, info, data.id); } }, ItemArmorSlot: { @@ -239,7 +242,7 @@ export default { return data.type; }, zones(data, args, context, info) { - return context.data.worker.item.getLocale(data.zones, context, info); + return context.data.worker.handbook.getLocale(data.zones, context, info); }, material(data, args, context, info) { return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); @@ -251,7 +254,7 @@ export default { return data.type; }, zones(data, args, context, info) { - return context.data.worker.item.getLocale(data.zones, context, info); + return context.data.worker.handbook.getLocale(data.zones, context, info); }, allowedPlates(data, args, context, info) { return data.allowedPlates.map(id => context.data.worker.item.getItem(context, info, id)); @@ -306,13 +309,13 @@ export default { }, ItemPropertiesArmor: { armorType(data, args, context, info) { - return context.data.worker.item.getLocale(data.armorType, context, info); + return context.data.worker.handbook.getLocale(data.armorType, context, info); }, material(data, args, context, info) { return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, zones(data, args, context, info) { - return context.data.worker.item.getLocale(data.zones, context, info); + return context.data.worker.handbook.getLocale(data.zones, context, info); }, }, ItemPropertiesArmorAttachment: { @@ -320,10 +323,10 @@ export default { return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, headZones(data, args, context, info) { - return context.data.worker.item.getLocale(data.headZones, context, info); + return context.data.worker.handbook.getLocale(data.headZones, context, info); }, zones(data, args, context, info) { - return context.data.worker.item.getLocale(data.headZones, context, info); + return context.data.worker.handbook.getLocale(data.headZones, context, info); } }, ItemPropertiesBackpack: { @@ -333,13 +336,13 @@ export default { }, ItemPropertiesChestRig: { armorType(data, args, context, info) { - return context.data.worker.item.getLocale(data.armorType, context, info); + return context.data.worker.handbook.getLocale(data.armorType, context, info); }, material(data, args, context, info) { return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, zones(data, args, context, info) { - return context.data.worker.item.getLocale(data.zones, context, info); + return context.data.worker.handbook.getLocale(data.zones, context, info); }, pouches(data) { return data.grids; @@ -352,13 +355,13 @@ export default { }, ItemPropertiesHelmet: { armorType(data, args, context, info) { - return context.data.worker.item.getLocale(data.armorType, context, info); + return context.data.worker.handbook.getLocale(data.armorType, context, info); }, material(data, args, context, info) { return context.data.worker.handbook.getArmorMaterial(context, info, data.armor_material_id); }, headZones(data, args, context, info) { - return context.data.worker.item.getLocale(data.headZones, context, info); + return context.data.worker.handbook.getLocale(data.headZones, context, info); } }, ItemPropertiesMagazine: { @@ -377,7 +380,7 @@ export default { return context.data.worker.item.getItem(context, info, data.default_ammo_id); }, fireModes(data, args, context, info) { - return context.data.worker.item.getLocale(data.fireModes, context, info); + return context.data.worker.handbook.getLocale(data.fireModes, context, info); }, allowedAmmo(data, args, context, info) { return data.allowedAmmo.map(id => context.data.worker.item.getItem(context, info, id)); @@ -392,7 +395,7 @@ export default { }, ItemSlot: { name(data, ags, context, info) { - return context.data.worker.item.getLocale(data.name, context, info); + return context.data.worker.handbook.getLocale(data.name, context, info); } }, ContainedItem: { @@ -434,7 +437,7 @@ export default { }, StimEffect: { type(data, args, context, info) { - return context.data.worker.item.getLocale(data.type, context, info); + return context.data.worker.handbook.getLocale(data.type, context, info); }, skill(data, args, context, info) { return context.data.worker.handbook.getSkill(context, info, data.skillName); From 50fd894248f33e829fa53cb826770908eabf344c Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Fri, 3 Jan 2025 15:00:39 -0600 Subject: [PATCH 6/8] fix ammo query --- datasources/handbook.mjs | 5 +++++ datasources/items.mjs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/datasources/handbook.mjs b/datasources/handbook.mjs index 4d61d10f..c35ad00a 100644 --- a/datasources/handbook.mjs +++ b/datasources/handbook.mjs @@ -86,6 +86,11 @@ class HandbookAPI extends WorkerKV { return cache.PlayerLevel; } + async getAllItemProperties(context, info) { + const { cache } = await this.getCache(context, info); + return cache.ItemProperties; + } + async getItemProperties(context, info, itemId) { const { cache } = await this.getCache(context, info); return cache.ItemProperties[itemId]; diff --git a/datasources/items.mjs b/datasources/items.mjs index d8554e1c..149a7173 100644 --- a/datasources/items.mjs +++ b/datasources/items.mjs @@ -226,10 +226,11 @@ class ItemsAPI extends WorkerKV { // ignore bb return ammoItems.filter(item => item.id !== '6241c316234b593b5676b637'); }); + const itemProperties = await context.data.worker.handbook.getAllItemProperties(context, info); return allAmmo.map(item => { return { ...item, - ...item.properties + ...itemProperties[item.id], }; }); } From 36687fc0fe74e1f5c69a53987a48ad016a52c1ed Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Wed, 8 Jan 2025 07:04:44 -0600 Subject: [PATCH 7/8] translate armor slot names --- resolvers/itemResolver.mjs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/resolvers/itemResolver.mjs b/resolvers/itemResolver.mjs index 26468717..dad50e35 100644 --- a/resolvers/itemResolver.mjs +++ b/resolvers/itemResolver.mjs @@ -237,9 +237,8 @@ export default { } }, ItemArmorSlotLocked: { - name(data) { - if (data.name) return data.name; - return data.type; + name(data, args, context, info) { + return context.data.worker.handbook.getLocale(data.name, context, info); }, zones(data, args, context, info) { return context.data.worker.handbook.getLocale(data.zones, context, info); @@ -249,9 +248,8 @@ export default { }, }, ItemArmorSlotOpen: { - name(data) { - if (data.name) return data.name; - return data.type; + name(data, args, context, info) { + return context.data.worker.handbook.getLocale(data.name, context, info); }, zones(data, args, context, info) { return context.data.worker.handbook.getLocale(data.zones, context, info); From 01e7f597a144f05bbefebb415088f0b6a44c42e0 Mon Sep 17 00:00:00 2001 From: Razzmatazz Date: Mon, 20 Jan 2025 12:50:24 -0600 Subject: [PATCH 8/8] add gameMode param to itemPrices query --- schema-static.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema-static.mjs b/schema-static.mjs index 79495359..3edf7ff0 100644 --- a/schema-static.mjs +++ b/schema-static.mjs @@ -1383,7 +1383,7 @@ type Query { historicalItemPrices(id: ID!, days: Int, lang: LanguageCode, gameMode: GameMode, limit: Int, offset: Int): [historicalPricePoint]! item(id: ID, normalizedName: String, lang: LanguageCode, gameMode: GameMode): Item items(ids: [ID], name: String, names: [String], type: ItemType, types: [ItemType], categoryNames: [ItemCategoryName], handbookCategoryNames: [HandbookCategoryName] bsgCategoryId: String, bsgCategoryIds: [String], bsgCategory: String, lang: LanguageCode, gameMode: GameMode, limit: Int, offset: Int): [Item]! - itemPrices(id: ID!, limit: Int, offset: Int): [historicalPricePoint]! + itemPrices(id: ID!, gameMode: GameMode, limit: Int, offset: Int): [historicalPricePoint]! itemCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]! goonReports(lang: LanguageCode, gameMode: GameMode, limit: Int, ofset: Int): [GoonReport]! handbookCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]!