cfdp / opeka

Counseling chat service, built for providing anonymous help to young people at risk
https://curachat.com
GNU General Public License v3.0
10 stars 6 forks source link

Finished #96: Added column: 'session duration' to statistics table #97

Closed alex-bukach closed 7 years ago

benjamin-dk commented 7 years ago

@alex-bukach after clicking the "leave room" button as an anonymous client, the chat crashes and I get the error


[19 Jun 09:37:37 - Info: Saved chat duration into stats.
2017-06-19T09:37:39.068Z - info: Regular user disconnected. 2050cc9c-05fb-4bab-9ca1-8a0e991229c6
2017-06-19T09:37:39.069Z - info: User logout: No valid reference to client.
2017-06-19T09:37:39.069Z - info: User logout: Chat duration (minutes):  1
/home/demo/opeka/nodejs/lib/opeka.js:1256
      opeka.statistics.saveChatDuration(removedUser.stats_id, chatDuration);
                                                   ^

TypeError: Cannot read property 'stats_id' of null
    at Server.self.removeUserFromRoom (/home/demo/opeka/nodejs/lib/opeka.js:1256:52)
    at /home/demo/opeka/nodejs/lib/opeka.js:1175:14
    at Array.forEach (native)
    at /home/demo/opeka/nodejs/lib/opeka.js:1159:37
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)]

The chat duration is saved correctly, but it seems that the method is called twice, and the second time the removedUser isn't initialized.

alex-bukach commented 7 years ago

@benjamin-dk I have just pushed the fix.

benjamin-dk commented 7 years ago

Merged in 0ea836c