Browse Source

Merge pull request #42 from dandevaud/bugfix/several-bugfixes

Added further date ranges
pull/5027/head
dandevaud 2 years ago
committed by GitHub
parent
commit
7e04140776
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      apps/api/src/app/portfolio/portfolio.service.ts
  2. 2
      apps/api/src/app/user/update-user-setting.dto.ts
  3. 3
      apps/client/src/app/components/toggle/toggle.component.ts
  4. 2
      libs/common/src/lib/types/date-range.type.ts

23
apps/api/src/app/portfolio/portfolio.service.ts

@ -72,6 +72,7 @@ import {
set, set,
setDayOfYear, setDayOfYear,
subDays, subDays,
subMonths,
subYears subYears
} from 'date-fns'; } from 'date-fns';
import { isEmpty, sortBy, uniq, uniqBy } from 'lodash'; import { isEmpty, sortBy, uniq, uniqBy } from 'lodash';
@ -1624,6 +1625,28 @@ export class PortfolioService {
setDayOfYear(new Date().setHours(0, 0, 0, 0), 1) setDayOfYear(new Date().setHours(0, 0, 0, 0), 1)
]); ]);
break; break;
case '1w':
portfolioStart = max([
portfolioStart,
subDays(new Date().setHours(0, 0, 0, 0), 7)
]);
break;
case '1m':
portfolioStart = max([
portfolioStart,
subMonths(new Date().setHours(0, 0, 0, 0), 1)
]);
break;
case '3m':
portfolioStart = max([
portfolioStart,
subMonths(new Date().setHours(0, 0, 0, 0), 3)
]);
break;
case '1y': case '1y':
portfolioStart = max([ portfolioStart = max([
portfolioStart, portfolioStart,

2
apps/api/src/app/user/update-user-setting.dto.ts

@ -29,7 +29,7 @@ export class UpdateUserSettingDto {
@IsOptional() @IsOptional()
colorScheme?: ColorScheme; colorScheme?: ColorScheme;
@IsIn(<DateRange[]>['1d', '1y', '5y', 'max', 'ytd']) @IsIn(<DateRange[]>['1d', '1w', '1m', '3m', '1y', '5y', 'max', 'ytd'])
@IsOptional() @IsOptional()
dateRange?: DateRange; dateRange?: DateRange;

3
apps/client/src/app/components/toggle/toggle.component.ts

@ -19,6 +19,9 @@ import { ToggleOption } from '@ghostfolio/common/types';
export class ToggleComponent implements OnChanges, OnInit { export class ToggleComponent implements OnChanges, OnInit {
public static DEFAULT_DATE_RANGE_OPTIONS: ToggleOption[] = [ public static DEFAULT_DATE_RANGE_OPTIONS: ToggleOption[] = [
{ label: $localize`Today`, value: '1d' }, { label: $localize`Today`, value: '1d' },
{ label: $localize`1W`, value: '1w' },
{ label: $localize`1M`, value: '1m' },
{ label: $localize`3M`, value: '3m' },
{ label: $localize`YTD`, value: 'ytd' }, { label: $localize`YTD`, value: 'ytd' },
{ label: $localize`1Y`, value: '1y' }, { label: $localize`1Y`, value: '1y' },
{ label: $localize`5Y`, value: '5y' }, { label: $localize`5Y`, value: '5y' },

2
libs/common/src/lib/types/date-range.type.ts

@ -1 +1 @@
export type DateRange = '1d' | '1y' | '5y' | 'max' | 'ytd'; export type DateRange = '1d' | '1w' | '1m' | '3m' | '1y' | '5y' | 'max' | 'ytd';

Loading…
Cancel
Save