<commit_before>const Router = require('express-promise-router');
const router = Router();

const Stages = require('../models/stage');
const Submissions = require('../models/submission');
const sequelize = require('../models');

router.get('/', async (req, res) => {
	const since = new Date(req.query.since || 0);
	const limit = req.query.limit ? parseInt(req.query.limit) : 20;

	const submissions = await Submissions.findAll({
		attributes: [
			'name',
			[sequelize.fn('sum', sequelize.col('score')), 'totalScore'],
		],
		include: [{
			model: Stages,
			where: {
				migratedVersion: {
					$col: 'submissions.version',
				},
			},
		}],
		group: ['submissions.name'],
		order: [
			[sequelize.fn('sum', sequelize.col('score')), 'DESC'],
		],
		where: {
			updatedAt: {
				$gte: since,
			},
		},
		limit,
		raw: true,
	});
<commit_msg>Fix postgres problem???<commit_after>const Router = require('express-promise-router');
const router = Router();

const Stages = require('../models/stage');
const Submissions = require('../models/submission');
const sequelize = require('../models');

router.get('/', async (req, res) => {
	const since = new Date(req.query.since || 0);
	const limit = req.query.limit ? parseInt(req.query.limit) : 20;

	const submissions = await Submissions.findAll({
		attributes: [
			'name',
			[sequelize.fn('sum', sequelize.col('score')), 'totalScore'],
		],
		include: [{
			model: Stages,
			attributes: [],
			where: {
				migratedVersion: {
					$col: 'submissions.version',
				},
			},
		}],
		group: ['submissions.name'],
		order: [
			[sequelize.fn('sum', sequelize.col('score')), 'DESC'],
		],
		where: {
			updatedAt: {
				$gte: since,
			},
		},
		limit,
		raw: true,
	});

{'fraction_non_alphanumeric': 0.20116618075801748, 'fraction_numerical': 0.003498542274052478, 'mean_word_length': 3.5638297872340425, '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': '4080321', 'n_tokens_mistral': 695, 'n_tokens_neox': 591, 'n_words': 119}