<commit_before>const {knex} = require('../util/database').connect();
import _ from 'lodash';
import {deepChangeKeyCase} from '../util';

function getTeams() {
  return knex.raw(`
  SELECT teams.id, teams.name, teams.image_path,
    SUM(COALESCE(action_types.value, 0)) AS score
  FROM teams
  LEFT JOIN actions ON teams.id = actions.team_id
  LEFT JOIN action_types ON actions.action_type_id = action_types.id
  GROUP BY teams.id, teams.name
  ORDER BY score DESC, teams.id`)
  .then(result => {
    return _.map(result.rows, row => deepChangeKeyCase(row, 'camelCase'));
  });
}

export {
  getTeams
};<commit_msg>Don't count banned actions to score<commit_after>const {knex} = require('../util/database').connect();
import _ from 'lodash';
import {deepChangeKeyCase} from '../util';

function getTeams() {
  return knex.raw(`
  SELECT teams.id, teams.name, teams.image_path,
    SUM(COALESCE(action_types.value, 0)) AS score
  FROM teams
  LEFT JOIN actions ON teams.id = actions.team_id AND NOT actions.is_banned
  LEFT JOIN action_types ON actions.action_type_id = action_types.id
  GROUP BY teams.id, teams.name
  ORDER BY score DESC, teams.id`)
  .then(result => {
    return _.map(result.rows, row => deepChangeKeyCase(row, 'camelCase'));
  });
}

export {
  getTeams
};
{'fraction_non_alphanumeric': 0.13479623824451412, 'fraction_numerical': 0.001567398119122257, 'mean_word_length': 4.233606557377049, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6921265', 'n_tokens_mistral': 450, 'n_tokens_neox': 426, 'n_words': 114}