<commit_before>'use strict';

var dot = require('dot');
dot.templateSettings.strip = false;

var Node = require('../node');

var queryTemplate = dot.template([
    'WITH',
    '_cdb_analysis_points AS (',
    ' {{=it.pointsQuery}}',
    '),',
    '_cdb_analysis_polygons AS (',
    ' {{=it.polygonsQuery}}',
    ')',
    'SELECT {{=it.pointsColumns}}',
    'FROM _cdb_analysis_points JOIN _cdb_analysis_polygons',
    'ON ST_Contains(_cdb_analysis_polygons.the_geom, _cdb_analysis_points.the_geom)'
].join('\n'));

function query(it) {
    it.pointsColumns = it.columnNames.map(function(name) { return '_cdb_analysis_points.' + name; }).join(', ');
    return queryTemplate(it);
}

var TYPE = 'point-in-polygon';
var PARAMS = {
    points_source: Node.PARAM.NODE,
    polygons_source: Node.PARAM.NODE
};

var PointInPolygon = Node.create(TYPE, PARAMS);

module.exports = PointInPolygon;
module.exports.TYPE = TYPE;
module.exports.PARAMS = PARAMS;
module.exports.create = require('./factory').create;


PointInPolygon.prototype._getQuery = function() {
    return query({
        pointsQuery: this.points_source.getQuery(),
        polygonsQuery: this.polygons_source.getQuery(),
        columnNames: this.columns
    });
};
<commit_msg>Use columns from points source<commit_after>'use strict';

var dot = require('dot');
dot.templateSettings.strip = false;

var Node = require('../node');

var queryTemplate = dot.template([
    'WITH',
    '_cdb_analysis_points AS (',
    ' {{=it.pointsQuery}}',
    '),',
    '_cdb_analysis_polygons AS (',
    ' {{=it.polygonsQuery}}',
    ')',
    'SELECT {{=it.pointsColumns}}',
    'FROM _cdb_analysis_points JOIN _cdb_analysis_polygons',
    'ON ST_Contains(_cdb_analysis_polygons.the_geom, _cdb_analysis_points.the_geom)'
].join('\n'));

function query(it) {
    it.pointsColumns = it.columnNames.map(function(name) { return '_cdb_analysis_points.' + name; }).join(', ');
    return queryTemplate(it);
}

var TYPE = 'point-in-polygon';
var PARAMS = {
    points_source: Node.PARAM.NODE,
    polygons_source: Node.PARAM.NODE
};

var PointInPolygon = Node.create(TYPE, PARAMS);

module.exports = PointInPolygon;
module.exports.TYPE = TYPE;
module.exports.PARAMS = PARAMS;
module.exports.create = require('./factory').create;


PointInPolygon.prototype._getQuery = function() {
    return query({
        pointsQuery: this.points_source.getQuery(),
        polygonsQuery: this.polygons_source.getQuery(),
        columnNames: this.points_source.getColumns()
    });
};

{'fraction_non_alphanumeric': 0.15749601275917066, 'fraction_numerical': 0.0, 'mean_word_length': 4.183884297520661, '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': '3945295', 'n_tokens_mistral': 855, 'n_tokens_neox': 844, 'n_words': 146}