{"size": 497, "ext": "js", "max_stars_repo_path": "src/server/api/controllers/getAllUsers.controller.js", "max_stars_repo_name": "JohnYazji/24-June", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/server/api/controllers/getAllUsers.controller.js", "max_issues_repo_name": "JohnYazji/24-June", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/server/api/controllers/getAllUsers.controller.js", "max_forks_repo_name": "JohnYazji/24-June", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.1578947368, "max_line_length": 75, "alphanum_fraction": 0.5995975855}
const knex = require('../../config/db');

const getAllUsers = async () => {
  try {
    return await knex('users')
      .join('game_instances', 'users.id', '=', 'game_instances.fk_user_id')
      .join('game_scores', 'users.id', '=', 'game_scores.fk_user_id')
      .select('users.name', 'game_scores.score')
      .where ('game_instances.finished', '=', '1')
      .orderBy('game_scores.score', 'desc');
  } catch (error) {
    return error.message;
  }
};

module.exports = {
  getAllUsers,
};
