Add `/.well-known/matrix/client` for Matrix clients
[gitter.git] / scripts / graphs / one-to-ones-csv.js
blob9c44c0140c58fb1a480a6704489478dcb461e0e7
1 'use strict';
3 var persistence = require('gitter-web-persistence');
4 var shutdown = require('shutdown');
5 var es = require('event-stream');
6 var csv = require('fast-csv');
7 var fs = require('fs');
9 persistence.Troupe.find({ oneToOne: true })
10   .lean()
11   .select('users')
12   .slaveOk()
13   .stream()
14   .pipe(
15     es.map(function(room, callback) {
16       if (room.users.length !== 2) return callback();
18       callback(null, {
19         userA: '' + room.users[0].userId,
20         userB: '' + room.users[1].userId
21       });
22     })
23   )
24   .on('end', function() {
25     setTimeout(function() {
26       shutdown.shutdownGracefully();
27     }, 10000);
28   })
29   .pipe(csv.createWriteStream({ headers: true }))
30   .pipe(fs.createWriteStream('one-to-ones.csv'));