Skip to content
Snippets Groups Projects
Commit 1ea88b9f authored by L4168's avatar L4168
Browse files

format data for group cluster

parent 43ab21fa
No related branches found
No related tags found
3 merge requests!59Development to master,!58Development to testing,!56Cluster update to Development
......@@ -77,28 +77,46 @@ export class TrackingService {
let factions = await this.factionRepository.find({ game: gameId });
playerdata = await Promise.all(
factions.map(async faction => {
return await this.trackingrepository.find({
let rawdata = await this.trackingrepository.find({
where: { faction: faction.factionId },
relations: ['faction', 'gamepersonId'],
});
let groups = {
'infantry.svg': [],
'recon.svg': [],
'mechanized.svg': [],
};
rawdata.forEach(async player => {
groups[player.icon].push(player);
});
return groups;
}),
);
}
// parse data
// create an array for each faction
// inside faction create an array for each icon type
// insisde icon arrays include all players with same icon
const currentdata = await Promise.all(
await playerdata.map(async faction => {
return await Promise.all(
faction.map(async player => {
return await {
gamepersonId: player['gamepersonId']['gamepersonId'],
gamepersonRole: player['gamepersonId']['role'],
factionId: player['faction']['factionId'],
factionColour: player['faction']['colour'],
icon: player['icon'],
coordinates: player['data'].pop(),
};
}),
);
let data = [];
for (let group in faction) {
data.push(
await Promise.all(
faction[group].map(async player => {
return await {
gamepersonId: player['gamepersonId']['gamepersonId'],
gamepersonRole: player['gamepersonId']['role'],
factionId: player['faction']['factionId'],
factionColour: player['faction']['colour'],
icon: player['icon'],
coordinates: player['data'].pop(),
};
}),
),
);
}
return data;
}),
);
return currentdata;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment