@@ -191,55 +191,35 @@ export class WebSocketServer {
191191 }
192192 // Lets assume only robots register queues ( not true )
193193 if ( cli . clientagent == "openrpa" ) {
194- DatabaseConnection . mongodb_update_count . labels ( "users" ) . inc ( ) ;
195- const end = DatabaseConnection . mongodb_update . startTimer ( ) ;
196- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } ,
197- { $set : { _rpaheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
198- console . error ( err ) ;
199- } ) ;
200- end ( { collection : "users" } ) ;
194+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
195+ { $set : { _rpaheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
196+ Config . prometheus_measure_onlineuser , null ) ;
201197 }
202198 if ( cli . clientagent == "nodered" ) {
203- DatabaseConnection . mongodb_update_count . labels ( "users" ) . inc ( ) ;
204- const end = DatabaseConnection . mongodb_update . startTimer ( ) ;
205- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } ,
206- { $set : { _noderedheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
207- console . error ( err ) ;
208- } ) ;
209- end ( { collection : "users" } ) ;
199+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
200+ { $set : { _noderedheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
201+ Config . prometheus_measure_onlineuser , null ) ;
210202 }
211203 if ( cli . clientagent == "webapp" || cli . clientagent == "aiotwebapp" ) {
212- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } ,
213- { $set : { _webheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
214- console . error ( err ) ;
215- } ) ;
204+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
205+ { $set : { _webheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
206+ Config . prometheus_measure_onlineuser , null ) ;
216207 }
217208 if ( cli . clientagent == "powershell" ) {
218- DatabaseConnection . mongodb_update_count . labels ( "users" ) . inc ( ) ;
219- const end = DatabaseConnection . mongodb_update . startTimer ( ) ;
220- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } ,
221- { $set : { _powershellheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
222- console . error ( err ) ;
223- } ) ;
224- end ( { collection : "users" } ) ;
209+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
210+ { $set : { _powershellheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
211+ Config . prometheus_measure_onlineuser , null ) ;
225212 }
226213 if ( cli . clientagent == "mobileapp" || cli . clientagent == "aiotmobileapp" ) {
227- DatabaseConnection . mongodb_update_count . labels ( "users" ) . inc ( ) ;
228- const end = DatabaseConnection . mongodb_update . startTimer ( ) ;
229- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } ,
230- { $set : { _webheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _mobilheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
231- console . error ( err ) ;
232- } ) ;
233- end ( { collection : "users" } ) ;
214+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
215+ { $set : { _webheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _mobilheartbeat : new Date ( new Date ( ) . toISOString ( ) ) , _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
216+ Config . prometheus_measure_onlineuser , null ) ;
234217 }
235218 else {
236219 // Should proberly turn this a little down, so we dont update all online users every 10th second
237- DatabaseConnection . mongodb_update_count . labels ( "users" ) . inc ( ) ;
238- const end = DatabaseConnection . mongodb_update . startTimer ( ) ;
239- Config . db . db . collection ( "users" ) . updateOne ( { _id : cli . user . _id } , { $set : { _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ) . catch ( ( err ) => {
240- console . error ( err ) ;
241- } ) ;
242- end ( { collection : "users" } ) ;
220+ Config . db . synRawUpdateOne ( "users" , { _id : cli . user . _id } ,
221+ { $set : { _heartbeat : new Date ( new Date ( ) . toISOString ( ) ) } } ,
222+ Config . prometheus_measure_onlineuser , null ) ;
243223 }
244224 }
245225 } catch ( error ) {
0 commit comments