forked from couchbaselabs/sync-gateway-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiagnose.js
53 lines (36 loc) · 1.14 KB
/
diagnose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var coax = require("coax")
// var dbURL = "http://sync.couchbasecloud.com:4984/guestok67/"
if (!process.argv[2]) {
console.log("usage: node diagnose.js http://localhost:4984/my-database")
process.exit(1)
}
console.log(process.argv[2])
var dbURL = process.argv[2]
var db = coax(dbURL)
db("_changes", function (err, data) {
var changes = data.results.map(function(r){return r.id});
db("_all_docs", function(err, view){
var docs = view.rows;
var missing = [];
docs.forEach(function(d){
if (changes.indexOf(d.id) == -1) {
missing.push(d.id)
}
})
var changeIds = {}, dupIds = [];
var changeSeqs = {}, dupSeqs = [];
data.results.forEach(function(r){
if (changeIds[r.id]) {
dupIds.push(r.id)
}
changeIds[r.id] = true
if (changeSeqs[r.seq]) {
dupSeqs.push(r.seq)
}
changeSeqs[r.seq] = true
})
console.log("missing "+missing.length+", ids:", missing.join(', '))
console.log("duplicate change ids "+dupIds.length+", ids:", dupIds.join(', '))
console.log("duplicate change seqs "+dupSeqs.length+", seqs:", dupSeqs.join(', '))
})
})