1
1
import { IQueryHandler , QueryHandler } from "@nestjs/cqrs" ;
2
2
import { InjectRepository } from "@nestjs/typeorm" ;
3
- import { And , LessThan , MoreThan , Repository } from "typeorm" ;
3
+ import { Between , Repository } from "typeorm" ;
4
4
5
5
import { UserIdService } from "src/core/authentication" ;
6
6
import { map , mapArray } from "src/core/mapper" ;
@@ -9,15 +9,15 @@ import { QueryService } from "src/core/query";
9
9
import { JournalEntry } from "../../../infrastructure/entities/journal-entry.entity" ;
10
10
import { JournalDetails } from "../../contracts/dtos/journal-details.dto" ;
11
11
import { JournalEntryDetails } from "../../contracts/dtos/journal-entry-details.dto" ;
12
- import { GetJournalQuery } from "../../contracts/queries/get-journal.query" ;
12
+ import { GetProfileJournalQuery } from "../../contracts/queries/get-profile -journal.query" ;
13
13
14
14
function formatCommandName ( commandName : string ) : string {
15
15
return commandName . replace ( / C o m m a n d $ / , "" ) ;
16
16
}
17
17
18
- @QueryHandler ( GetJournalQuery )
19
- export class GetJournalHandler
20
- implements IQueryHandler < GetJournalQuery , JournalDetails >
18
+ @QueryHandler ( GetProfileJournalQuery )
19
+ export class GetProfileJournalHandler
20
+ implements IQueryHandler < GetProfileJournalQuery , JournalDetails >
21
21
{
22
22
constructor (
23
23
@InjectRepository ( JournalEntry )
@@ -26,7 +26,7 @@ export class GetJournalHandler
26
26
private readonly userIdService : UserIdService ,
27
27
) { }
28
28
29
- async execute ( query : GetJournalQuery ) {
29
+ async execute ( query : GetProfileJournalQuery ) {
30
30
const userId = this . userIdService . getUserId ( ) ;
31
31
32
32
const foundJournalEntries = await this . queryService . find (
@@ -38,7 +38,7 @@ export class GetJournalHandler
38
38
query,
39
39
required : {
40
40
where : {
41
- created : And ( LessThan ( query . to ) , MoreThan ( query . from ) ) ,
41
+ created : Between ( query . from , query . to ) ,
42
42
userId,
43
43
} ,
44
44
} ,
0 commit comments