{"size": 1201, "ext": "js", "max_stars_repo_path": "scripts/remove_old_issues.js", "max_stars_repo_name": "alfonso-presa/mirrorgate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "scripts/remove_old_issues.js", "max_issues_repo_name": "alfonso-presa/mirrorgate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scripts/remove_old_issues.js", "max_forks_repo_name": "alfonso-presa/mirrorgate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.4594594595, "max_line_length": 75, "alphanum_fraction": 0.6860949209}
/*
 * Copyright 2017 Banco Bilbao Vizcaya Argentaria, S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var db;

if(typeof mongo_user == "undefined"){
    var conn = new Mongo();
    db = conn.getDB(mongo_authdb);
} else {
    db = connect(mongo_host + ":" + mongo_port + "/" + mongo_authdb);
    db.auth(mongo_user,mongo_pass);
    db = db.getSiblingDB(mongo_authdb);
}

var purgeDate = new Date(new Date().setMonth(new Date().getMonth() - 3));

'Removing old issues until: ' + purgeDate;

db.getCollection('feature').find({
  timestamp: {'$lt' : purgeDate.getTime()},
  sTypeName: { $nin : [ "Bug", "Epic", "Feature"]},
  sStatus: "Done",
  sSprintAssetState: { $ne : 'ACTIVE'}
});