text: const _ = require('lodash');
  const gamePlayService = require('../services/gamePlay');
  const DB = require('../services/db.service');
  module.exports = {
    measuremenstInput: async (req, res, next) => {
      try {
        //input validation
        const { game_session_name, player_name, measurements } = _.get(
          req,
          'body'
        );
        if (
          !game_session_name ||
          !player_name ||
          !measurements ||
          !_.size(measurements)
        ) {
          return res.status(400).send('Missing data');
        }
        const gamePlay = new gamePlayService(
          game_session_name,
          player_name,
          measurements
        );
  
        const skills = await gamePlay.calculateInputMeasurement();
        await DB.createPlayer(
          game_session_name,
          player_name,
          measurements,
          skills
        );
  
        return res.status(200).send(skills);
      } catch (error) {
        return res.status(500).send(error);
      }
    },
    getSessionGames: async (req, res, next) => {
      try {
        const sessionGames = await DB.getSessionGames();
        return res.status(200).send(sessionGames);
      } catch (error) {
        return res.status(500).send(error);
      }
    },
    getSessionGameById: async (req, res, next) => {
      try {
        const gameSessionId = +_.get(req, 'params.id');
        if (!gameSessionId) {
          return res.status(400).send('session Id is mandatory');
        }
        const gameSession = await DB.getSessionGameByID(gameSessionId);
        return res.status(200).send(gameSession ? gameSession : {});
      } catch (error) {
        return res.status(500).send(error);
      }
    },
    updatePlayerNameByPlayerId: async (req, res, next) => {
      try {
        const { player_id, player_name } = _.get(req, 'body');
        const updatePlayer = await DB.updatePlayerByPlayerId(
          player_id,
          player_name
        );
        return res.status(200).send(updatePlayer);
      } catch (error) {
        return res.status(500).send(error);
      }
    },
  };
  