Explorar o código

Fix bug where error would occur trying to access id property of thread, when thread was deleted, and hence null

sbkwgh %!s(int64=7) %!d(string=hai) anos
pai
achega
cc3a981cb2
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      routes/log.js

+ 3 - 0
routes/log.js

@@ -124,6 +124,9 @@ router.get('/top-threads', async (req, res, next) => {
 
 		//Sum each log for a thread
 		let pageViewsObj = logs.reduce((obj, log) => {
+			//E.g. if thread deleted
+			if(!log.Thread) return obj;
+
 			if(!obj[log.Thread.id]) {
 				obj[log.Thread.id] = { Thread: log.Thread, pageViews: 1 }
 			} else {