diff --git a/apps/api/src/shops/shop.service.ts b/apps/api/src/shops/shop.service.ts index 19e5a79..c8726ee 100644 --- a/apps/api/src/shops/shop.service.ts +++ b/apps/api/src/shops/shop.service.ts @@ -117,11 +117,16 @@ export class ShopService { }); // One read for the whole view: every reputation requirement needs a - // display name, and offers commonly gate on the same faction. + // display name, and offers commonly gate on the same faction. Restricted + // to enabled factions because that is what the condition engine evaluates + // against -- naming a faction the engine treats as absent would describe a + // requirement that can never be met. const factionNames = new Map( - (await this.dataSource.getRepository(ReputationFaction).find()).map( - (faction) => [faction.key, faction.name], - ), + ( + await this.dataSource + .getRepository(ReputationFaction) + .find({ where: { enabled: true } }) + ).map((faction) => [faction.key, faction.name]), ); const context = { characterId, npcId }; @@ -205,6 +210,9 @@ export class ShopService { const offers = await manager.getRepository(ShopOffer).find({ where: { shopId: shop.id, enabled: true }, relations: { itemDefinition: true, lootBagDefinition: true }, + // Same order as the view: both paths answer "which offer does this key + // mean", so neither may answer it from an arbitrary row order. + order: { sortOrder: 'ASC' }, }); let match: ShopOffer | undefined; let target: OfferTarget | undefined;