<commit_before>'use strict';

var Db = require('../config/database');
var mongoose = require('mongoose');

var TagSchema = mongoose.Schema({
    title          : {type: String, required: true},
    coordinates: {
        lat        : {type: Number, required: true},
        lon        : {type: Number, required: true}
    },
    tag            : {type: String, required: true},
    owner          : {type: String, required: true},
    creationDate   : {type: Date  , default : Date.now},
    expirationDate : {type: Date  , required: true},
    score          : {type: Number, default : 0}
});

var TagMongoModel = Db.model('tags', TagSchema);

function createTag(title, lat, lon, tag, owner, ttl, callback) {
    var newTag = {
        title          : title,
        coordinates: {
            lat        : lat,
            lon        : lon
        },
        tag            : tag,
        owner          : owner,
        expirationDate : Date.now() + ttl  // How to set expiration time in the DB?
    }

    TagMongoModel.create(newTag, function(err, tag) {
        callback(err, tag);
    });
}

var TagModel = {
    create: createTag

    // TODO: getTag??
};

module.exports = TagModel;
<commit_msg>Added location to schema<commit_after>'use strict';

var Db       = require('../config/database');
var mongoose = require('mongoose');

var TagSchema = mongoose.Schema({
    title          : {type: String, required: true},
    location       : {type: String, required: true},
    coordinates: {
        lat        : {type: Number, required: true},
        lon        : {type: Number, required: true}
    },
    tag            : {type: String, required: true},
    owner          : {type: String, required: true},
    createdAt      : {type: Date  , default : Date.now},
    expires        : {type: Date  , required: true},
    score          : {type: Number, default : 0}
});

var TagMongoModel = Db.model('tags', TagSchema);

function createTag(title, loc, lat, lon, tag, owner, ttl, callback) {
    var newTag = {
        title          : title,
        location       : loc,
        coordinates: {
            lat        : lat,
            lon        : lon
        },
        tag            : tag,
        owner          : owner,
        expirationDate : Date.now() + ttl  // How to set expiration time in the DB?
    }

    TagMongoModel.create(newTag, function(err, tag) {
        callback(err, tag);
    });
}

var TagModel = {
    create: createTag

    // TODO: getTag??
};

module.exports = TagModel;

{'fraction_non_alphanumeric': 0.12882703777335985, 'fraction_numerical': 0.0007952286282306163, 'mean_word_length': 1.8397291196388261, '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': '7609083', 'n_tokens_mistral': 744, 'n_tokens_neox': 741, 'n_words': 213}