<commit_before>var pg = require( 'pg' ),
	db = require( './db' );
	
exports.add = function( req, res ) {
	var client = new pg.Client( db.conn );
	client.connect();
	
	var queryString = "INSERT INTO neighborhood_collection ( name, uuid, confidence, comments, geom, tool_used ) VALUES( ";
	
	queryString += "'" + req.body.name.replace(/[']/g, "''") + "', ";
	queryString += "'" + req.body.uuid + "', ";
	queryString += req.body.confidence + ", ";
	queryString += req.body.comments ? "'" + req.body.comments.replace(/[']/g, "''") + "', " : "NULL, ";
	queryString += "ST_GeomFromGeoJSON( '" + req.body.geojson + "' ),";
	queryString += "'" + req.body.tool_used + "' )";

	var query = client.query( queryString );
	
	query.on( 'end', function() {
		res.send( req.body.name );
		client.end();
	});
}

exports.delete = function( req, res ) {
	var client = new pg.Client( db.conn );
	client.connect();
	
	var query = client.query( "DELETE FROM neighborhood_collection WHERE gid = ANY ( ARRAY ( SELECT gid FROM neighborhoods_collection WHERE uuid = '" + req.params.uuid + "' AND name = '" + req.params.name + "' ORDER BY added DESC LIMIT 1 ) )" );
	
	query.on( 'end', function() {
		res.send( "DELETED" );
		client.end();
	})
}
<commit_msg>Set neighborhood variable to result from form<commit_after>var pg = require( 'pg' ),
	db = require( './db' );
	
exports.add = function( req, res ) {
	var client = new pg.Client( db.conn );
	client.connect();
	
	var neighborhoodType = ( req.body.neighborhood === "neighborhood" ) ? "neighborhoods_collection" : "superneighborhoods_collection";
	
	var queryString = "INSERT INTO " + neighborhoodType + " ( name, uuid, confidence, comments, geom, tool_used ) VALUES( ";
	
	queryString += "'" + req.body.name.replace(/[']/g, "''") + "', ";
	queryString += "'" + req.body.uuid + "', ";
	queryString += req.body.confidence + ", ";
	queryString += req.body.comments ? "'" + req.body.comments.replace(/[']/g, "''") + "', " : "NULL, ";
	queryString += "ST_GeomFromGeoJSON( '" + req.body.geojson + "' ),";
	queryString += "'" + req.body.tool_used + "' )";

	var query = client.query( queryString );
	
	query.on( 'end', function() {
		res.send( req.body.name );
		client.end();
	});
}

exports.delete = function( req, res ) {
	var client = new pg.Client( db.conn );
	client.connect();
	
	var query = client.query( "DELETE FROM neighborhood_collection WHERE gid = ANY ( ARRAY ( SELECT gid FROM neighborhoods_collection WHERE uuid = '" + req.params.uuid + "' AND name = '" + req.params.name + "' ORDER BY added DESC LIMIT 1 ) )" );
	
	query.on( 'end', function() {
		res.send( "DELETED" );
		client.end();
	})
}

{'fraction_non_alphanumeric': 0.20038022813688214, 'fraction_numerical': 0.0007604562737642585, 'mean_word_length': 3.7320143884892087, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3695416', 'n_tokens_mistral': 926, 'n_tokens_neox': 875, 'n_words': 204}