Remove logs and rename variables

This commit is contained in:
Evan Morikawa 2016-07-14 16:36:13 -07:00
parent 5b3f5c8a91
commit 1eef4c3428
3 changed files with 9 additions and 16 deletions

View file

@ -39,12 +39,6 @@ function createOutputStream() {
const outputStream = require('stream').Readable();
outputStream._read = () => { return };
outputStream.pushJSON = (msg) => {
try {
if (typeof msg === 'string') {
const parsed = JSON.parse(msg)
console.log(parsed.id, parsed.event, parsed.object, parsed.objectId)
}
} catch (err) {}
const jsonMsg = typeof msg === 'string' ? msg : JSON.stringify(msg);
outputStream.push(jsonMsg);
}
@ -65,15 +59,10 @@ function initialTransactions(db, request) {
function inflatedDeltas(db, request) {
return PubsubConnector.observeDeltas(request.auth.credentials.id)
.flatMap((dataValues) => {
const flat = [db.Transaction.build(dataValues)]
console.log('DV', dataValues)
return flat
})
.flatMap((transactionJSON) => [db.Transaction.build(transactionJSON)])
.flatMap((objs) => inflateTransactions(db, objs))
}
module.exports = (server) => {
server.route({
method: 'GET',

View file

@ -94,6 +94,10 @@ module.exports = (sequelize, Sequelize) => {
throw new Error("Message.toJSON called on a message where folder were not eagerly loaded.")
}
// When we request messages as a sub-object of a thread, we only
// request the `id` field from the database. We still toJSON the
// Message though and need to protect `this.date` from null
// errors.
return {
id: this.id,
account_id: this.accountId,

View file

@ -73,8 +73,8 @@ class PubsubConnector {
return this._observableForChannelOnSharedListener(`account-${accountId}`);
}
notifyDelta(accountId, dataValues) {
this.broadcastClient().publish(`deltas-${accountId}`, JSON.stringify(dataValues))
notifyDelta(accountId, transactionJSON) {
this.broadcastClient().publish(`deltas-${accountId}`, JSON.stringify(transactionJSON))
}
observeAllAccounts() {
@ -93,8 +93,8 @@ class PubsubConnector {
observeDeltas(accountId) {
return Rx.Observable.create((observer) => {
const sub = this.buildClient();
sub.on("message", (channel, dataValuesString) => {
observer.onNext(JSON.parse(dataValuesString))
sub.on("message", (channel, transactionJSONString) => {
observer.onNext(JSON.parse(transactionJSONString))
})
sub.subscribe(`deltas-${accountId}`);
return () => {