Skip to content

Commit

Permalink
Fixed some issues on the bgs report
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakMukhopadhyay committed Jul 13, 2017
1 parent a828d1d commit b804f87
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/modules/discord/commands/bgsReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -95,17 +95,20 @@ 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;
let indexOfSystem = systems.findIndex(x => x.system_name === faction.system_name);
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);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/discord/commands/monitorFactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/discord/commands/monitorSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -87,7 +88,6 @@ export class MonitorSystems {
{ guild_id: guildId },
{
updated_at: new Date(),
primary: primary,
$addToSet: { monitor_systems: monitorSystems }
})
.then(guild => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/eddn/schemas/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b804f87

Please sign in to comment.