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

function createAction(action) {
    console.log(action);
  const dbRow = {
    'team_id': action.team,
    'action_type_id': knex.raw('(SELECT id from action_types WHERE code = ?)', [action.type]),
    'user_id': knex.raw('(SELECT id from users WHERE uuid = ?)', [action.user]),
    // Tuple is in longitude, latitude format in Postgis
    location: action.location.longitude + ',' + action.location.longitude,
    'image_url': action.image_url
  };

  if (action.payload) {
    dbRow.payload = action.payload;
  }

  return knex('actions').returning('*').insert(dbRow)
    .then(rows => {
      if (_.isEmpty(rows)) {
        throw new Error('Action row creation failed: ' + dbRow);
      }

      return rows.length;
    });
}<commit_msg>Removed saving of payload since it's not used anymoring<commit_after>import _ from 'lodash';
const {knex} = require('../util/database').connect();

function createAction(action) {
    console.log(action);
  const dbRow = {
    'team_id': action.team,
    'action_type_id': knex.raw('(SELECT id from action_types WHERE code = ?)', [action.type]),
    'user_id': knex.raw('(SELECT id from users WHERE uuid = ?)', [action.user]),
    // Tuple is in longitude, latitude format in Postgis
    location: action.location.longitude + ',' + action.location.longitude,
    'image_url': action.image_url
  };

  return knex('actions').returning('*').insert(dbRow)
    .then(rows => {
      if (_.isEmpty(rows)) {
        throw new Error('Action row creation failed: ' + dbRow);
      }

      return rows.length;
    });
}
{'fraction_non_alphanumeric': 0.16048632218844985, 'fraction_numerical': 0.0, 'mean_word_length': 3.4486486486486485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4297775', 'n_tokens_mistral': 532, 'n_tokens_neox': 522, 'n_words': 124}