From b804f87fe958c28e0899c2cd8fb2e39012bb0307 Mon Sep 17 00:00:00 2001 From: Sayak Mukhopadhyay Date: Fri, 14 Jul 2017 01:42:06 +0530 Subject: [PATCH] Fixed some issues on the bgs report --- src/modules/discord/commands/bgsReport.ts | 11 +++++++---- src/modules/discord/commands/monitorFactions.ts | 4 ++-- src/modules/discord/commands/monitorSystems.ts | 2 +- src/modules/eddn/schemas/journal.ts | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/discord/commands/bgsReport.ts b/src/modules/discord/commands/bgsReport.ts index 6645e31..6e3340c 100644 --- a/src/modules/discord/commands/bgsReport.ts +++ b/src/modules/discord/commands/bgsReport.ts @@ -68,7 +68,7 @@ export class BGSReport { secondarySystems.push(system.system_name); } }); - this.db.model.faction.find({ faction_name: { $in: primaryFactions } }) + this.db.model.faction.find({ faction_name_lower: { $in: primaryFactions } }) .then(factions => { if (factions) { let embed = new discord.RichEmbed(); @@ -79,7 +79,7 @@ export class BGSReport { embed.addField(faction.faction_name, "------------", false); faction.faction_presence.forEach((faction) => { let systemReport = ""; - systemReport += `Current ${factionAcronym} Influence : ${(faction.influence * 100).toFixed(1)}\n`; + systemReport += `Current ${factionAcronym} Influence : ${(faction.influence * 100).toFixed(1)}%\n`; systemReport += `Current ${factionAcronym} State : ${faction.state}\n`; let pendingStates: string = ""; if (faction.pending_states.length === 0) { @@ -95,7 +95,7 @@ export class BGSReport { } systemReport += `Pending ${factionAcronym} States : ${pendingStates}\n`; secondaryFactions.forEach(otherFaction => { - this.db.model.faction.findOne({ faction_name: otherFaction }) + this.db.model.faction.findOne({ faction_name_lower: otherFaction }) .then(otherFaction => { if (otherFaction) { let systems = otherFaction.faction_presence; @@ -103,9 +103,12 @@ export class BGSReport { if (indexOfSystem !== -1) { let factionAcronym = this.acronym(otherFaction.faction_name); let otherSystem = otherFaction.faction_presence[indexOfSystem]; - systemReport += `Current ${factionAcronym} Influence : ${(otherSystem.influence * 100).toFixed(1)} (Currently in ${otherSystem.state})\n`; + systemReport += `Current ${factionAcronym} Influence : ${(otherSystem.influence * 100).toFixed(1)}% (Currently in ${otherSystem.state})\n`; } } + }) + .catch(err => { + console.log(err); }); }); embed.addField(faction.system_name, systemReport); diff --git a/src/modules/discord/commands/monitorFactions.ts b/src/modules/discord/commands/monitorFactions.ts index 5f4ace2..a193d28 100644 --- a/src/modules/discord/commands/monitorFactions.ts +++ b/src/modules/discord/commands/monitorFactions.ts @@ -76,13 +76,13 @@ export class MonitorFactions { let factionName = responseObject[0].name; let factionNameLower = responseObject[0].name_lower; let monitorFactions = { - faction_name: factionNameLower + faction_name: factionNameLower, + primary: primary, } this.db.model.guild.findOneAndUpdate( { guild_id: guildId }, { updated_at: new Date(), - primary: primary, $addToSet: { monitor_factions: monitorFactions } }) .then(guild => { diff --git a/src/modules/discord/commands/monitorSystems.ts b/src/modules/discord/commands/monitorSystems.ts index 1e29a88..826feb5 100644 --- a/src/modules/discord/commands/monitorSystems.ts +++ b/src/modules/discord/commands/monitorSystems.ts @@ -77,6 +77,7 @@ export class MonitorSystems { let systemNameLower = responseObject[0].name_lower; let monitorSystems = { system_name: systemNameLower, + primary: primary, system_pos: { x: responseObject[0].x, y: responseObject[0].y, @@ -87,7 +88,6 @@ export class MonitorSystems { { guild_id: guildId }, { updated_at: new Date(), - primary: primary, $addToSet: { monitor_systems: monitorSystems } }) .then(guild => { diff --git a/src/modules/eddn/schemas/journal.ts b/src/modules/eddn/schemas/journal.ts index c063df7..5c4f376 100644 --- a/src/modules/eddn/schemas/journal.ts +++ b/src/modules/eddn/schemas/journal.ts @@ -18,7 +18,7 @@ import { DB } from '../../../db/index'; import App from '../../../server'; export class Journal { - public static readonly schemaId: string = "http://schemas.elite-markets.net/eddn/journal/1/test"; + public static readonly schemaId: string = "http://schemas.elite-markets.net/eddn/journal/1"; private message: any; private timestamp: string; private event: string;