Skip to content

Commit

Permalink
chore: improve tracks and search
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmykane committed Oct 21, 2020
1 parent 16aaf86 commit 7eebd6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
9 changes: 6 additions & 3 deletions src/app/components/event-search/event-search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
</mat-button-toggle-group>
<mat-button-toggle-group [value]="selectedDateRange"
(change)="dateToggleChange($event)">
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.lastThirtyDays) !== -1" [value]="dateRanges.lastThirtyDays" aria-label="Last 30 days">
Last 30 days
</mat-button-toggle>
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.thisMonth) !== -1" [value]="dateRanges.thisMonth" aria-label="This month">
This month
</mat-button-toggle>
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.lastThirtyDays) !== -1" [value]="dateRanges.lastThirtyDays" aria-label="Last 30 days">
Last 30 days
</mat-button-toggle>
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.lastMonth) !== -1" [value]="dateRanges.lastMonth" aria-label="Last month">
Last month
</mat-button-toggle>
Expand All @@ -60,6 +60,9 @@
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.lastYear) !== -1" [value]="dateRanges.lastYear" aria-label="Last year">
{{currentYear - 1}}
</mat-button-toggle>
</mat-button-toggle-group>
<mat-button-toggle-group [value]="selectedDateRange"
(change)="dateToggleChange($event)">
<mat-button-toggle *ngIf="dateRangesToShow.indexOf(dateRanges.all) !== -1" [value]="dateRanges.all" aria-label="All">
All
</mat-button-toggle>
Expand Down
28 changes: 16 additions & 12 deletions src/app/components/tracks/tracks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class TracksComponent implements OnInit, OnDestroy {
DateRanges.thisMonth,
DateRanges.lastThirtyDays,
DateRanges.thisYear,
// DateRanges.lastYear,
DateRanges.all,
]
bufferProgress = new Subject<number>();
totalProgress = new Subject<number>();
Expand Down Expand Up @@ -126,18 +126,22 @@ export class TracksComponent implements OnInit, OnDestroy {
this.clearProgressAndOpenBottomSheet();
const dates = getDatesForDateRange(dateRange, user.settings.unitSettings.startOfTheWeek);
const where = []
where.push({
fieldPath: 'startDate',
opStr: <WhereFilterOp>'>=',
value: dates.startDate.getTime()
});
where.push({
fieldPath: 'startDate',
opStr: <WhereFilterOp>'<=', // Should remove mins from date
value: dates.endDate.getTime()
});
if (dates.startDate) {
where.push({
fieldPath: 'startDate',
opStr: <WhereFilterOp>'>=',
value: dates.startDate.getTime()
});
}
if (dates.endDate) {
where.push({
fieldPath: 'startDate',
opStr: <WhereFilterOp>'<=', // Should remove mins from date
value: dates.endDate.getTime()
})
}

this.eventsSubscription = this.eventService.getEventsBy(user, where, 'startDate', null, 500).subscribe(async (events) => {
this.eventsSubscription = this.eventService.getEventsBy(user, where, 'startDate', true, 0).subscribe(async (events) => {
events = events.filter((event) => event.getStat(DataStartPosition.type));
if (!events || !events.length) {
return;
Expand Down
6 changes: 0 additions & 6 deletions src/app/helpers/date-range-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ export function getDatesForDateRange(dateRange: DateRanges, startOfTheWeek: Days
endDate: new Date(new Date(new Date().getFullYear(), 0, 0).setHours(23, 59, 59))
}
}
case DateRanges.custom: {
return {
startDate: null,
endDate: null
}
}
default: {
return {
startDate: null,
Expand Down

0 comments on commit 7eebd6b

Please sign in to comment.