From 152724b793319568580a5b2f24c673f4af4638e5 Mon Sep 17 00:00:00 2001
From: Samuli Virtapohja <l4721@student.jamk.fi>
Date: Mon, 22 Jul 2019 14:52:15 +0300
Subject: [PATCH] get-group changes

---
 package-lock.json              | 28 +++++++---------------------
 src/faction/faction.service.ts | 23 +++++++++++++++++++++--
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 73ad73b..01d2eb7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3146,14 +3146,12 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -3168,20 +3166,17 @@
         "code-point-at": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "concat-map": {
           "version": "0.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -3298,8 +3293,7 @@
         "inherits": {
           "version": "2.0.3",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "ini": {
           "version": "1.3.5",
@@ -3311,7 +3305,6 @@
           "version": "1.0.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -3326,7 +3319,6 @@
           "version": "3.0.4",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -3334,14 +3326,12 @@
         "minimist": {
           "version": "0.0.8",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -3360,7 +3350,6 @@
           "version": "0.5.1",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -3441,8 +3430,7 @@
         "number-is-nan": {
           "version": "1.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -3454,7 +3442,6 @@
           "version": "1.4.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -3576,7 +3563,6 @@
           "version": "1.0.2",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
diff --git a/src/faction/faction.service.ts b/src/faction/faction.service.ts
index 3229986..ae6b40a 100644
--- a/src/faction/faction.service.ts
+++ b/src/faction/faction.service.ts
@@ -132,10 +132,29 @@ export class FactionService {
 
   // get the groups in the given Faction
   async showGroups(factionId) {
-    return await this.game_GroupRepository.find({
-      relations: ['leader', 'players'],
+    let groups = await this.game_GroupRepository.find({
       where: { faction: factionId },
+      relations: ['leader', 'leader.person', 'players', 'players.person'],
     });
+
+    let players = await Promise.all(
+      groups.map(async group => {
+        let groupPlayers = await Promise.all(
+          group.players.map(async player => {
+            return await player.person.name;
+          }),
+        );
+        return await {
+          id: group.id,
+          name: group.name,
+          class: group.class,
+          players: groupPlayers,
+          leader: group.leader.person.name,
+        };
+      }),
+    );
+
+    return players;
   }
 
   // puts a non admin or faction leader player into a specified group
-- 
GitLab