Last active
August 29, 2015 14:08
-
-
Save aaronj1335/d0808c5de46ee13ad3f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inUseFilterIds = {}; | |
var start = Date.now(); | |
function elapsed(start) { | |
return (Date.now() - start) / 1e3; | |
} | |
print('creating lookup of in-use filter id\'s'); | |
db.broadcast.find().forEach(function(broadcast) { | |
var smsBroadcast = broadcast.smsBroadcast || {}; | |
var lists = smsBroadcast.filteredLists || []; | |
lists.forEach(function(dbRef) { | |
inUseFilterIds[dbRef.getId().str] = true; | |
}); | |
}); | |
print('created look-up of in-use filter id\'s (', elapsed(start), 'elapsed )'); | |
db.unusedQueryFilterIds.drop(); | |
db.createCollection('unusedQueryFilterIds'); | |
db.unusedQueryFilterIds.ensureIndex({ | |
queryFilter: 1 | |
}, { | |
unique: true | |
}); | |
start = Date.now(); | |
print('creating unusedQueryFilterIds collection'); | |
db.queryFilter.find().limit(100000).forEach(function(queryFilter) { | |
if (!(queryFilter._id.str in inUseFilterIds)) | |
db.unusedQueryFilterIds.insert({ | |
queryFilter: DBRef('queryFilter', queryFilter._id) | |
}); | |
}); | |
print('created unusedQueryFilterIds collection of', | |
db.unusedQueryFilterIds.count(), '(', elapsed(start), 'elapsed )'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment