<commit_before>var Troll = require('troll-opt').Troll;
var models = require('./models/');
var fs = require('fs');
var utils = require('./utils.js');

var buildInfo = (new Troll()).options(function(troll) {
	troll.banner('Adds a new incremental build to the database.');
	troll.opt('timestamp', 'The build\'s timestamp as "unixepoch" timestamp ("ro.build.date.utc").', { type: 'integer', required: true });
	troll.opt('md5sum', 'The build\'s md5sum.', { type: 'string', required: true });
	troll.opt('filename', 'The resulting filename.', { type: 'string', required: true });
	troll.opt('subdirectory', 'The subdirectory from which the file can be downloaded.', { type: 'string' });
	troll.opt('from_target_files', 'The name of the "target files ZIP" of the incremental\'s "source".', { type: 'string', required: true });
	troll.opt('to_target_files', 'The name of the "target files ZIP" of the incremental\'s "target".', { type: 'string', required: true });
});

function createNewIncremental(sourceRom, targetRom) {
	var buildTimestamp = utils.toDate(buildInfo.timestamp);

	models.Incremental.build({
		sourceRomId: sourceRom.id,
		targetRomId: targetRom.id,
		timestamp: buildTimestamp,
		md5sum: buildInfo.md5sum,
		filename: buildInfo.filename,
		subdirectory: buildInfo.subdirectory,
	}).save().success(function(newRom) {
		console.log('Successfully created new incremental: ' + JSON.stringify(newRom));
	});
}

var findRomWithTargetFilesZipName = function(targetFilesZipName, subdirectory) {
	return models.Rom.find({ where: {
		targetFilesZipName: targetFilesZipName,
		subdirectory: subdirectory }
	});
}

models.sequelize.sync().success(function() {
	findRomWithTargetFilesZipName(buildInfo.from_target_files, buildInfo.subdirectory).success(function(sourceRom) {
		if (sourceRom) {
			findRomWithTargetFilesZipName(buildInfo.to_target_files, buildInfo.subdirectory).success(function(targetRom) {
				if (targetRom) {
					createNewIncremental(sourceRom, targetRom);
				} else {
					console.log('Target rom with targetFilesZipName "' + buildInfo.to_target_files + '" not found.');
				}
			});
		} else {
			console.log('Source rom with targetFilesZipName "' + buildInfo.from_target_files + '" not found.');
		}
	});
});<commit_msg>Use string format syntax instead of concatenating strings.<commit_after>var Troll = require('troll-opt').Troll;
var models = require('./models/');
var fs = require('fs');
var utils = require('./utils.js');

var buildInfo = (new Troll()).options(function(troll) {
	troll.banner('Adds a new incremental build to the database.');
	troll.opt('timestamp', 'The build\'s timestamp as "unixepoch" timestamp ("ro.build.date.utc").', { type: 'integer', required: true });
	troll.opt('md5sum', 'The build\'s md5sum.', { type: 'string', required: true });
	troll.opt('filename', 'The resulting filename.', { type: 'string', required: true });
	troll.opt('subdirectory', 'The subdirectory from which the file can be downloaded.', { type: 'string' });
	troll.opt('from_target_files', 'The name of the "target files ZIP" of the incremental\'s "source".', { type: 'string', required: true });
	troll.opt('to_target_files', 'The name of the "target files ZIP" of the incremental\'s "target".', { type: 'string', required: true });
});

function createNewIncremental(sourceRom, targetRom) {
	var buildTimestamp = utils.toDate(buildInfo.timestamp);

	models.Incremental.build({
		sourceRomId: sourceRom.id,
		targetRomId: targetRom.id,
		timestamp: buildTimestamp,
		md5sum: buildInfo.md5sum,
		filename: buildInfo.filename,
		subdirectory: buildInfo.subdirectory,
	}).save().success(function(newRom) {
		console.log('Successfully created new incremental: ' + JSON.stringify(newRom));
	});
}

var findRomWithTargetFilesZipName = function(targetFilesZipName, subdirectory) {
	return models.Rom.find({ where: {
		targetFilesZipName: targetFilesZipName,
		subdirectory: subdirectory }
	});
}

models.sequelize.sync().success(function() {
	findRomWithTargetFilesZipName(buildInfo.from_target_files, buildInfo.subdirectory).success(function(sourceRom) {
		if (sourceRom) {
			findRomWithTargetFilesZipName(buildInfo.to_target_files, buildInfo.subdirectory).success(function(targetRom) {
				if (targetRom) {
					createNewIncremental(sourceRom, targetRom);
				} else {
					console.log('Target rom with targetFilesZipName "%s" not found.', buildInfo.to_target_files);
				}
			});
		} else {
			console.log('Source rom with targetFilesZipName "%s" not found.', buildInfo.from_target_files);
		}
	});
});
{'fraction_non_alphanumeric': 0.15093922651933703, 'fraction_numerical': 0.0017679558011049724, 'mean_word_length': 5.493543758967001, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5478884', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1398, 'n_words': 327}