| 
									
										
										
										
											2017-11-03 22:08:27 -04:00
										 |  |  | const sql = require('./sql'); | 
					
						
							|  |  |  | const utils = require('./utils'); | 
					
						
							| 
									
										
										
										
											2017-11-05 21:56:42 -05:00
										 |  |  | const log = require('./log'); | 
					
						
							| 
									
										
										
										
											2017-11-03 22:08:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 17:04:47 -05:00
										 |  |  | async function addEvent(db, comment) { | 
					
						
							|  |  |  |     await addNoteEvent(db, null, comment); | 
					
						
							| 
									
										
										
										
											2017-11-03 22:08:27 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 17:04:47 -05:00
										 |  |  | async function addNoteEvent(db, noteId, comment) { | 
					
						
							|  |  |  |     await sql.insert(db, 'event_log', { | 
					
						
							| 
									
										
										
										
											2017-11-03 22:08:27 -04:00
										 |  |  |        note_id : noteId, | 
					
						
							|  |  |  |        comment: comment, | 
					
						
							|  |  |  |        date_added: utils.nowTimestamp() | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-11-05 21:56:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     log.info("Event log for " + noteId + ": " + comment); | 
					
						
							| 
									
										
										
										
											2017-11-03 22:08:27 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = { | 
					
						
							|  |  |  |     addEvent, | 
					
						
							|  |  |  |     addNoteEvent | 
					
						
							|  |  |  | }; |