@@ -44,30 +44,36 @@ export class EncounterService {
4444 . leftJoinAndSelect ( "encounter.userReports" , "userReports" )
4545 . leftJoinAndSelect ( "encounter.messages" , "messages" )
4646 . leftJoinAndSelect ( "messages.sender" , "sender" )
47+ . leftJoinAndSelect ( "encounter.users" , "allUsers" )
4748 /** @DEV CHANGE! */
4849 . where (
4950 ':userId IN (SELECT "userId" FROM user_encounters_encounter WHERE "encounterId" = encounter.id)' ,
5051 { userId } ,
5152 )
52- . andWhere ( "userReports.id IS NULL" )
53- . leftJoinAndSelect ( "encounter.users" , "allUsers" ) ;
53+ . andWhere ( "userReports.id IS NULL" ) ;
5454
5555 if ( dateRange ?. startDate && dateRange ?. endDate ) {
5656 query = query . andWhere (
57- "encounter.updated BETWEEN :startDate AND :endDate" ,
57+ "encounter.lastDateTimePassedBy BETWEEN :startDate AND :endDate" ,
5858 {
5959 startDate : dateRange . startDate ,
6060 endDate : dateRange . endDate ,
6161 } ,
6262 ) ;
6363 } else if ( dateRange ?. startDate ) {
64- query = query . andWhere ( "encounter.updated >= :startDate" , {
65- startDate : dateRange . startDate ,
66- } ) ;
64+ query = query . andWhere (
65+ "encounter.lastDateTimePassedBy >= :startDate" ,
66+ {
67+ startDate : dateRange . startDate ,
68+ } ,
69+ ) ;
6770 } else if ( dateRange ?. endDate ) {
68- query = query . andWhere ( "encounter.updated <= :endDate" , {
69- endDate : dateRange . endDate ,
70- } ) ;
71+ query = query . andWhere (
72+ "encounter.lastDateTimePassedBy <= :endDate" ,
73+ {
74+ endDate : dateRange . endDate ,
75+ } ,
76+ ) ;
7177 }
7278
7379 // do not fail if none found
0 commit comments