File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
src/app/modules/time-clock/services Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -143,10 +143,13 @@ describe('EntryService', () => {
143143
144144 it ( 'entries are found by project id with a limit 2 by default' , ( ) => {
145145 const projectId = 'project-id' ;
146+ const startDate = ( moment ( ) . subtract ( 1 , 'months' ) ) . format ( ) ;
147+ const endDate = moment ( ) . format ( ) ;
146148
147149 service . findEntriesByProjectId ( projectId ) . subscribe ( ) ;
148150
149- const restartEntryRequest = httpMock . expectOne ( `${ service . baseUrl } ?limit=2&project_id=${ projectId } ` ) ;
151+ const restartEntryRequest = httpMock . expectOne ( `${ service . baseUrl } ?limit=2&project_id=${ projectId } &start_date= ${ startDate } &end_date= ${ endDate } ` ) ;
150152 expect ( restartEntryRequest . request . method ) . toBe ( 'GET' ) ;
151153 } ) ;
154+
152155} ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { environment } from './../../../../environments/environment';
77import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
88import { DatePipe } from '@angular/common' ;
99import { Entry } from '../../shared/models' ;
10+ import * as moment from 'moment' ;
1011
1112@Injectable ( {
1213 providedIn : 'root' ,
@@ -59,7 +60,9 @@ export class EntryService {
5960 }
6061
6162 findEntriesByProjectId ( projectId : string ) : Observable < Entry [ ] > {
62- const findEntriesByProjectURL = `${ this . baseUrl } ?limit=2&project_id=${ projectId } ` ;
63+ const startDate = this . getDateLastMonth ( ) ;
64+ const endDate = this . getCurrentDate ( ) ;
65+ const findEntriesByProjectURL = `${ this . baseUrl } ?limit=2&project_id=${ projectId } &start_date=${ startDate } &end_date=${ endDate } ` ;
6366 return this . http . get < Entry [ ] > ( findEntriesByProjectURL ) ;
6467 }
6568
@@ -77,4 +80,12 @@ export class EntryService {
7780 }
7881 ) ;
7982 }
83+
84+ getDateLastMonth ( ) {
85+ return ( moment ( ) . subtract ( 1 , 'months' ) ) . format ( ) ;
86+ }
87+
88+ getCurrentDate ( ) {
89+ return moment ( ) . format ( ) ;
90+ }
8091}
You can’t perform that action at this time.
0 commit comments