Browse Source

Merge branch 'main' into bugfix/case-insensitive-sorting-in-platform-and-tag-management-of-admin-control-panel

pull/8425/head
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
d63ec9cda0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      CHANGELOG.md
  2. 202
      apps/api/src/services/activities/activities.service.ts
  3. 8
      apps/api/src/services/configuration/configuration.service.ts
  4. 40
      apps/api/src/services/twitter-bot/twitter-bot.service.ts
  5. 44
      apps/client/src/app/adapter/custom-paginator-intl.ts
  6. 3
      apps/client/src/app/app.component.ts
  7. 6
      apps/client/src/main.ts
  8. 10
      package-lock.json
  9. 2
      package.json

3
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Upgraded `dotenv` from version `18.0.9` to `18.0.10`
- Upgraded `ng-extract-i18n-merge` from version `3.4.0` to `3.5.0`
- Upgraded `prisma` from version `7.10.0` to `7.10.1`
- Upgraded `yahoo-finance2` from version `4.0.5` to `4.0.6`
@ -18,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the duplicate data point of today in the chart of the holding detail dialog
- Fixed the case-insensitive sorting in the platform management of the admin control panel
- Fixed the case-insensitive sorting in the tag management of the admin control panel
- Fixed the missing localization of the range label in the paginator
- Fixed the requests of the twitter bot service with dummy credentials
## 3.100.0 - 2026-11-15

202
apps/api/src/services/activities/activities.service.ts

@ -175,50 +175,58 @@ export class ActivitiesService {
assetClass?: AssetClass;
assetSubClass?: AssetSubClass;
symbol?: string;
SymbolProfile: {
connectOrCreate: Prisma.SymbolProfileCreateOrConnectWithoutActivitiesInput;
};
tags?: { id: string }[];
updateAccountBalance?: boolean;
userId: string;
}
): Promise<Prisma.OrderGetPayload<{ include: { SymbolProfile: true } }>> {
const tags = data.tags ?? [];
const {
accountId,
assetClass,
assetSubClass,
tags = [],
updateAccountBalance = false,
userId,
...orderInput
} = data;
await this.tagService.validateTagIds({
userId,
tagIds: tags.map(({ id }) => {
return id;
}),
userId: data.userId
})
});
let account:
Prisma.AccountCreateNestedOneWithoutActivitiesInput | undefined;
if (data.accountId) {
if (accountId) {
account = {
connect: {
id_userId: {
userId: data.userId,
id: data.accountId
userId,
id: accountId
}
}
};
}
const accountId = data.accountId;
const updateAccountBalance = data.updateAccountBalance ?? false;
const userId = data.userId;
const connectOrCreateSymbolProfile =
orderInput.SymbolProfile.connectOrCreate;
if (
NON_INVESTMENT_ACTIVITY_TYPES.includes(data.type) ||
(data.SymbolProfile.connectOrCreate.create.dataSource === 'MANUAL' &&
data.type === 'BUY')
NON_INVESTMENT_ACTIVITY_TYPES.includes(orderInput.type) ||
(connectOrCreateSymbolProfile.create.dataSource === 'MANUAL' &&
orderInput.type === 'BUY')
) {
const assetClass = data.assetClass;
const assetSubClass = data.assetSubClass;
const dataSource: DataSource = 'MANUAL';
const requestedSymbol = data.SymbolProfile.connectOrCreate.create.symbol;
const requestedSymbol = connectOrCreateSymbolProfile.create.symbol;
let name = data.SymbolProfile.connectOrCreate.create.name;
let name = connectOrCreateSymbolProfile.create.name;
let symbol: string;
const existingAssetProfile = hasGhostfolioPrefix(requestedSymbol)
@ -244,30 +252,30 @@ export class ActivitiesService {
symbol = randomUUID();
}
data.SymbolProfile.connectOrCreate.create.assetClass = assetClass;
data.SymbolProfile.connectOrCreate.create.assetSubClass = assetSubClass;
data.SymbolProfile.connectOrCreate.create.dataSource = dataSource;
data.SymbolProfile.connectOrCreate.create.name = name;
data.SymbolProfile.connectOrCreate.create.symbol = symbol;
data.SymbolProfile.connectOrCreate.create.userId = userId;
data.SymbolProfile.connectOrCreate.where.dataSource_symbol = {
connectOrCreateSymbolProfile.create.assetClass = assetClass;
connectOrCreateSymbolProfile.create.assetSubClass = assetSubClass;
connectOrCreateSymbolProfile.create.dataSource = dataSource;
connectOrCreateSymbolProfile.create.name = name;
connectOrCreateSymbolProfile.create.symbol = symbol;
connectOrCreateSymbolProfile.create.userId = userId;
connectOrCreateSymbolProfile.where.dataSource_symbol = {
dataSource,
symbol
};
}
if (data.SymbolProfile.connectOrCreate.create.dataSource !== 'MANUAL') {
if (connectOrCreateSymbolProfile.create.dataSource !== 'MANUAL') {
this.dataGatheringService.addJobToQueue({
data: {
dataSource: data.SymbolProfile.connectOrCreate.create.dataSource,
symbol: data.SymbolProfile.connectOrCreate.create.symbol
dataSource: connectOrCreateSymbolProfile.create.dataSource,
symbol: connectOrCreateSymbolProfile.create.symbol
},
name: GATHER_ASSET_PROFILE_PROCESS_JOB_NAME,
opts: {
...GATHER_ASSET_PROFILE_PROCESS_JOB_OPTIONS,
jobId: getAssetProfileIdentifier({
dataSource: data.SymbolProfile.connectOrCreate.create.dataSource,
symbol: data.SymbolProfile.connectOrCreate.create.symbol
dataSource: connectOrCreateSymbolProfile.create.dataSource,
symbol: connectOrCreateSymbolProfile.create.symbol
}),
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH,
removeOnComplete: {
@ -277,39 +285,31 @@ export class ActivitiesService {
});
}
delete data.accountId;
delete data.assetClass;
delete data.assetSubClass;
if (!data.comment) {
delete data.comment;
if (!orderInput.comment) {
delete orderInput.comment;
}
const assetProfile = await this.prismaService.symbolProfile.findUnique({
select: { currency: true },
where: data.SymbolProfile.connectOrCreate.where
where: connectOrCreateSymbolProfile.where
});
const assetProfileCurrency =
assetProfile?.currency ??
data.SymbolProfile.connectOrCreate.create.currency;
assetProfile?.currency ?? connectOrCreateSymbolProfile.create.currency;
if (data.currency === assetProfileCurrency) {
delete data.currency;
if (orderInput.currency === assetProfileCurrency) {
delete orderInput.currency;
}
delete data.symbol;
delete data.tags;
delete data.updateAccountBalance;
delete data.userId;
delete orderInput.symbol;
const orderData: Prisma.OrderCreateInput = data;
const orderData: Prisma.OrderCreateInput = orderInput;
const tagsToConnect = getTagsWithDraftTag({
tags,
date: data.date as Date,
date: orderInput.date as Date,
draftTag: { id: TAG_ID_DRAFT },
type: data.type
type: orderInput.type
});
const activity = await this.prismaService.order.create({
@ -384,7 +384,7 @@ export class ActivitiesService {
isBenchmark,
activitiesCount: symbolProfile.activitiesCount,
symbol: symbolProfile.symbol,
watchedByCount: symbolProfile.watchedByCount
watchedByCount: symbolProfile.watchedByCount ?? 0
})
) {
await this.marketDataService.deleteMany({
@ -463,7 +463,7 @@ export class ActivitiesService {
activitiesCount,
isBenchmark,
symbol,
watchedByCount
watchedByCount: watchedByCount ?? 0
})
) {
await this.marketDataService.deleteMany({ dataSource, symbol });
@ -512,6 +512,8 @@ export class ActivitiesService {
const startOfUtcDateOfTomorrow = getStartOfUtcDateOfTomorrow();
for (const account of cashDetails.accounts) {
const accountCurrency = account.currency ?? userCurrency;
const { balances } = await this.accountBalanceService.getAccountBalances({
userCurrency,
userId,
@ -541,27 +543,27 @@ export class ActivitiesService {
assetSubClass: AssetSubClass.CASH,
countries: [],
createdAt: new Date(balanceItem.date),
currency: account.currency,
currency: accountCurrency,
dataSource:
this.dataProviderService.getDataSourceForExchangeRates(),
holdings: [],
id: account.currency,
id: accountCurrency,
isActive: true,
name: account.currency,
name: accountCurrency,
sectors: [],
symbol: account.currency,
symbol: accountCurrency,
updatedAt: new Date(balanceItem.date)
},
comment: account.name,
createdAt: new Date(balanceItem.date),
currency: account.currency,
currency: accountCurrency,
date: new Date(balanceItem.date),
fee: 0,
feeInAssetProfileCurrency: 0,
feeInBaseCurrency: 0,
id: balanceItem.id,
quantity: 1,
symbolProfileId: account.currency,
symbolProfileId: accountCurrency,
type: ActivityType.BUY,
unitPrice: 1,
unitPriceInAssetProfileCurrency: 1,
@ -705,8 +707,18 @@ export class ActivitiesService {
}
}
const ordersWithSymbolProfile = orders.filter(
(
order
): order is OrderWithAccount & {
SymbolProfile: NonNullable<OrderWithAccount['SymbolProfile']>;
} => {
return Boolean(order.SymbolProfile);
}
);
const assetProfileIdentifiers = uniqBy(
orders.map(({ SymbolProfile }) => {
ordersWithSymbolProfile.map(({ SymbolProfile }) => {
return {
dataSource: SymbolProfile.dataSource,
symbol: SymbolProfile.symbol
@ -724,8 +736,8 @@ export class ActivitiesService {
assetProfileIdentifiers
);
const activities = await Promise.all(
orders.map(async (order) => {
const activities: Activity[] = await Promise.all(
ordersWithSymbolProfile.map(async (order) => {
const assetProfile = assetProfiles.find(({ dataSource, symbol }) => {
return (
dataSource === order.SymbolProfile.dataSource &&
@ -769,7 +781,7 @@ export class ActivitiesService {
return {
...omit(order, ['SymbolProfile']),
assetProfile,
assetProfile: assetProfile as EnhancedAssetProfile,
feeInAssetProfileCurrency,
feeInBaseCurrency,
unitPriceInAssetProfileCurrency,
@ -863,7 +875,7 @@ export class ActivitiesService {
return {
activitiesCount: _count as number,
dateOfFirstActivity: _min.date
dateOfFirstActivity: _min.date ?? undefined
};
}
@ -921,7 +933,7 @@ export class ActivitiesService {
assetSubClass?: AssetSubClass;
symbol?: string;
tags?: { id: string }[];
type?: ActivityType;
type: ActivityType;
};
originalDate: Date;
userId: string;
@ -941,14 +953,15 @@ export class ActivitiesService {
data.comment = null;
}
let assetProfileCurrency: string;
let assetProfileCurrency: string | undefined;
if (
NON_INVESTMENT_ACTIVITY_TYPES.includes(data.type) ||
(data.SymbolProfile.connect.dataSource_symbol.dataSource === 'MANUAL' &&
(data.SymbolProfile?.connect?.dataSource_symbol?.dataSource ===
'MANUAL' &&
data.type === 'BUY')
) {
delete data.SymbolProfile.connect;
delete data.SymbolProfile?.connect;
const activityToUpdate = await this.prismaService.order.findUnique({
select: { SymbolProfile: { select: { currency: true, userId: true } } },
@ -958,40 +971,47 @@ export class ActivitiesService {
assetProfileCurrency = activityToUpdate?.SymbolProfile.currency;
if (activityToUpdate?.SymbolProfile.userId === userId) {
data.SymbolProfile.update = {
data: {
assetClass: data.assetClass,
assetSubClass: data.assetSubClass
},
where: { userId }
};
if (data.SymbolProfile) {
data.SymbolProfile.update = {
data: {
assetClass: data.assetClass,
assetSubClass: data.assetSubClass
},
where: { userId }
};
}
} else {
delete data.SymbolProfile;
}
} else {
} else if (data.SymbolProfile) {
delete data.SymbolProfile.update;
const assetProfile = await this.prismaService.symbolProfile.findUnique({
select: { currency: true },
where: data.SymbolProfile.connect
});
if (data.SymbolProfile.connect) {
const assetProfile = await this.prismaService.symbolProfile.findUnique({
select: { currency: true },
where: data.SymbolProfile.connect
});
assetProfileCurrency = assetProfile?.currency;
assetProfileCurrency = assetProfile?.currency;
if (!isActivityInFuture({ date: data.date as Date })) {
// Gather symbol data of order in the background, if the date is not in
// the future
this.dataGatheringService.gatherSymbols({
dataGatheringItems: [
{
dataSource:
data.SymbolProfile.connect.dataSource_symbol.dataSource,
date: data.date as Date,
symbol: data.SymbolProfile.connect.dataSource_symbol.symbol
}
],
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH
});
if (
!isActivityInFuture({ date: data.date as Date }) &&
data.SymbolProfile.connect.dataSource_symbol
) {
// Gather symbol data of order in the background, if the date is not in
// the future
this.dataGatheringService.gatherSymbols({
dataGatheringItems: [
{
dataSource:
data.SymbolProfile.connect.dataSource_symbol.dataSource,
date: data.date as Date,
symbol: data.SymbolProfile.connect.dataSource_symbol.symbol
}
],
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH
});
}
}
}
@ -1209,7 +1229,7 @@ export class ActivitiesService {
});
}
if (types?.length > 0) {
if (types && types.length > 0) {
where.type = { in: types };
}

8
apps/api/src/services/configuration/configuration.service.ts

@ -148,10 +148,10 @@ export class ConfigurationService {
}),
STRIPE_SECRET_KEY: str({ default: '' }),
TRUST_PROXY: trustProxy({ default: '' }),
TWITTER_ACCESS_TOKEN: str({ default: 'dummyAccessToken' }),
TWITTER_ACCESS_TOKEN_SECRET: str({ default: 'dummyAccessTokenSecret' }),
TWITTER_API_KEY: str({ default: 'dummyApiKey' }),
TWITTER_API_SECRET: str({ default: 'dummyApiSecret' })
TWITTER_ACCESS_TOKEN: str({ default: '' }),
TWITTER_ACCESS_TOKEN_SECRET: str({ default: '' }),
TWITTER_API_KEY: str({ default: '' }),
TWITTER_API_SECRET: str({ default: '' })
});
}

40
apps/api/src/services/twitter-bot/twitter-bot.service.ts

@ -17,7 +17,7 @@ import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2';
export class TwitterBotService implements OnModuleInit {
private readonly logger = new Logger(TwitterBotService.name);
private twitterClient: TwitterApiReadWrite;
private twitterClient?: TwitterApiReadWrite;
public constructor(
private readonly benchmarkService: BenchmarkService,
@ -27,18 +27,40 @@ export class TwitterBotService implements OnModuleInit {
) {}
public onModuleInit() {
this.twitterClient = new TwitterApi({
accessSecret: this.configurationService.get(
'TWITTER_ACCESS_TOKEN_SECRET'
),
accessToken: this.configurationService.get('TWITTER_ACCESS_TOKEN'),
appKey: this.configurationService.get('TWITTER_API_KEY'),
appSecret: this.configurationService.get('TWITTER_API_SECRET')
}).readWrite;
const accessSecret = this.configurationService.get(
'TWITTER_ACCESS_TOKEN_SECRET'
);
const accessToken = this.configurationService.get('TWITTER_ACCESS_TOKEN');
const appKey = this.configurationService.get('TWITTER_API_KEY');
const appSecret = this.configurationService.get('TWITTER_API_SECRET');
const areCredentialsSet = !!(
accessSecret &&
accessToken &&
appKey &&
appSecret
);
if (areCredentialsSet) {
this.twitterClient = new TwitterApi({
accessSecret,
accessToken,
appKey,
appSecret
}).readWrite;
} else if (
this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX') &&
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')
) {
this.logger.warn(
'ENABLE_FEATURE_FEAR_AND_GREED_INDEX and ENABLE_FEATURE_SUBSCRIPTION are enabled, but not all TWITTER_* credentials are set. The twitter bot service does not post the Fear & Greed Index.'
);
}
}
public async tweetFearAndGreedIndex() {
if (
!this.twitterClient ||
!this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX') ||
isWeekend(new Date())
) {

44
apps/client/src/app/adapter/custom-paginator-intl.ts

@ -0,0 +1,44 @@
import { getLocale } from '@ghostfolio/common/helper';
import { Service } from '@angular/core';
import { MatPaginatorIntl } from '@angular/material/paginator';
@Service()
export class CustomPaginatorIntl extends MatPaginatorIntl {
private locale = getLocale();
/**
* Formats the range label with the number format of the locale
*/
public override getRangeLabel = (
page: number,
pageSize: number,
length: number
) => {
let range = this.formatNumber(0);
if (length > 0 && pageSize > 0) {
const startIndex = page * pageSize;
const endIndex =
startIndex < length
? Math.min(startIndex + pageSize, length)
: startIndex + pageSize;
range = `${this.formatNumber(startIndex + 1)} – ${this.formatNumber(endIndex)}`;
}
const total = this.formatNumber(Math.max(length, 0));
return `${range} ${$localize`of`} ${total}`;
};
public setLocale(aLocale: string) {
this.locale = aLocale;
this.changes.next();
}
private formatNumber(aNumber: number) {
return aNumber.toLocaleString(this.locale, { useGrouping: true });
}
}

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

@ -42,6 +42,7 @@ import { openOutline } from 'ionicons/icons';
import { DeviceDetectorService } from 'ngx-device-detector';
import { distinctUntilChanged, filter, map } from 'rxjs/operators';
import { CustomPaginatorIntl } from './adapter/custom-paginator-intl';
import { GfFooterComponent } from './components/footer/footer.component';
import { GfHeaderComponent } from './components/header/header.component';
import { GfHoldingDetailDialogComponent } from './components/holding-detail-dialog/holding-detail-dialog.component';
@ -85,6 +86,7 @@ export class GfAppComponent implements OnInit {
ImpersonationStorageService
);
private readonly notificationService = inject(NotificationService);
private readonly paginatorIntl = inject(CustomPaginatorIntl);
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly title = inject(Title);
@ -225,6 +227,7 @@ export class GfAppComponent implements OnInit {
.subscribe((locale) => {
if (locale) {
this.dateAdapter.setLocale(locale);
this.paginatorIntl.setLocale(locale);
}
});

6
apps/client/src/main.ts

@ -18,6 +18,7 @@ import {
MAT_DATE_FORMATS,
MatNativeDateModule
} from '@angular/material/core';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { bootstrapApplication } from '@angular/platform-browser';
@ -28,6 +29,7 @@ import { provideMarkdown } from 'ngx-markdown';
import { provideNgxSkeletonLoader } from 'ngx-skeleton-loader';
import { CustomDateAdapter } from './app/adapter/custom-date-adapter';
import { CustomPaginatorIntl } from './app/adapter/custom-paginator-intl';
import { DateFormats } from './app/adapter/date-formats';
import { GfAppComponent } from './app/app.component';
import { routes } from './app/app.routes';
@ -93,6 +95,10 @@ import { environment } from './environments/environment';
provide: MAT_DATE_FORMATS,
useValue: DateFormats
},
{
provide: MatPaginatorIntl,
useExisting: CustomPaginatorIntl
},
{
provide: TitleStrategy,
useClass: PageTitleStrategy

10
package-lock.json

@ -71,7 +71,7 @@
"countries-list": "3.4.1",
"countup.js": "2.10.1",
"date-fns": "4.4.0",
"dotenv": "18.0.9",
"dotenv": "18.0.10",
"dotenv-expand": "13.0.0",
"envalid": "9.0.0",
"express": "5.2.1",
@ -19697,12 +19697,12 @@
}
},
"node_modules/dotenv": {
"version": "18.0.9",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.9.tgz",
"integrity": "sha512-3fVOW4cB02R066PUSwn8O4TJyz9NckQl7F81blIbaq9jKBm2tSmOKky7ZHIXzGvkVPXCSn6jkpziBPZdGFs8Tw==",
"version": "18.0.10",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.10.tgz",
"integrity": "sha512-89FAA1xchzK2mxVWdr5F/0rldwiueXs6zJM86rO66EzekR1iBdiXRthyG+m5GvkJaFH3C2LESzamTkgndmLT2A==",
"license": "BSD-2-Clause",
"bin": {
"dotenv": "dist/index.cjs"
"dotenv": "dist/cli.cjs"
},
"engines": {
"node": ">=12"

2
package.json

@ -115,7 +115,7 @@
"countries-list": "3.4.1",
"countup.js": "2.10.1",
"date-fns": "4.4.0",
"dotenv": "18.0.9",
"dotenv": "18.0.10",
"dotenv-expand": "13.0.0",
"envalid": "9.0.0",
"express": "5.2.1",

Loading…
Cancel
Save