Skip to content

Commit

Permalink
Update Title, Fix Tests (#15)
Browse files Browse the repository at this point in the history
* Server Forwards Requests to Chatalytics Web

* First Dynamic Data Connected

* Pin package.son versions

* Change Background

* Fix Server Crash on Uncaught Exception

* Set Request timeout

* Client Subscribes to WebSocket

* Updates Chart

* Message Counter Hooked In

* Add Title Page Data, Fix Tests
  • Loading branch information
psastras committed Apr 20, 2016
1 parent fcece82 commit 5894082
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions __tests__/Index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ jest.mock('../client/stores/MainStore.js');
jest.mock('../client/images/logo.png');
jest.mock('../client/images/bg2.jpg');

jest.mock('../client/sources/MainSource.js');
jest.mock('../client/actions/MainActions.js');

import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
Expand Down
4 changes: 2 additions & 2 deletions client/components/Title/Title.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class TitleComponent extends Component {
<td width={100}>{this.state.event ? this.state.event.message_count : 0}</td><td>Messages Processed </td>
</tr>
<tr>
<td>2315</td><td>Words Analyzed</td>
<td>{this.state.event ? this.state.event.active_room_count : 0}</td><td>Active Rooms</td>
</tr>
<tr>
<td>53</td><td>Unique Users</td>
<td>{this.state.event ? this.state.event.active_user_count : 0}</td><td>Active Users</td>
</tr>
</tbody>
</table>
Expand Down
10 changes: 8 additions & 2 deletions server/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default class EventBus {
this.state = {
message_meter: new Measured.Meter(),
message_count: new Measured.Counter(),
start_time: (new Date()).getTime()
start_time: (new Date()).getTime(),
active_rooms: new Set(),
active_users: new Set()
}

setInterval(() => {
Expand All @@ -29,7 +31,9 @@ export default class EventBus {
this.subscribers.forEach((subscriber) => {
subscriber({ message_meter: this.state.message_meter.toJSON(),
message_count: this.state.message_count.toJSON(),
start_time: this.state.start_time });
start_time: this.state.start_time,
active_room_count: this.state.active_rooms.size,
active_user_count: this.state.active_users.size });
});
}

Expand All @@ -43,6 +47,8 @@ export default class EventBus {
let occurrences = message.event.occurrences || 1;
this.state.message_meter.mark(occurrences);
this.state.message_count.inc(occurrences);
this.state.active_rooms.add(message.event.roomName);
this.state.active_users.add(message.event.username);
}
}
}
4 changes: 0 additions & 4 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ process.on('uncaughtException', function (err) {
console.error('Caught exception: ' + err);
});

process.on('uncaughtException', function(err) {
console.error('Caught exception: ' + err);
});

let yamlLoader = new YamlLoader();
yamlLoader.add(path.join(__dirname, 'defaults.config.yaml'), { filterKeys: true });

Expand Down

0 comments on commit 5894082

Please sign in to comment.