Browse Source

Address review feedback for #7079

pull/7079/head
AkashNegi1 4 weeks ago
parent
commit
1eb1753ce7
  1. 1
      CHANGELOG.md
  2. 2
      apps/api/src/app/asset/asset.controller.ts
  3. 2
      apps/api/src/app/asset/asset.module.ts
  4. 12
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts
  5. 4
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.module.ts
  6. 4
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts
  7. 4
      libs/common/src/lib/interfaces/index.ts
  8. 2
      libs/common/src/lib/interfaces/responses/asset-profile-response.interface.ts
  9. 4
      libs/ui/src/lib/services/data.service.ts

1
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Moved the endpoint to get the asset profile details from `GET api/v1/market-data/:dataSource/:symbol` to `GET api/v1/asset-profiles/:dataSource/:symbol`
- Moved the endpoint to get the asset profiles from `GET api/v1/admin/market-data` to `GET api/v1/asset-profiles` - Moved the endpoint to get the asset profiles from `GET api/v1/admin/market-data` to `GET api/v1/asset-profiles`
- Added the selected asset profile count to the delete menu item of the historical market data table in the admin control panel - Added the selected asset profile count to the delete menu item of the historical market data table in the admin control panel
- Added the selected asset profile count to the deletion confirmation dialog of the historical market data table in the admin control panel - Added the selected asset profile count to the deletion confirmation dialog of the historical market data table in the admin control panel

2
apps/api/src/app/asset/asset.controller.ts

@ -21,7 +21,7 @@ export class AssetController {
@Param('symbol') symbol: string @Param('symbol') symbol: string
): Promise<AssetResponse> { ): Promise<AssetResponse> {
const { assetProfile, marketData } = const { assetProfile, marketData } =
await this.assetProfilesService.getMarketDataBySymbol({ await this.assetProfilesService.getAssetProfile({
dataSource, dataSource,
symbol symbol
}); });

2
apps/api/src/app/asset/asset.module.ts

@ -1,9 +1,9 @@
import { AssetProfilesModule } from '@ghostfolio/api/app/endpoints/asset-profiles/asset-profiles.module';
import { TransformDataSourceInRequestModule } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.module'; import { TransformDataSourceInRequestModule } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.module';
import { TransformDataSourceInResponseModule } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.module'; import { TransformDataSourceInResponseModule } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.module';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AssetProfilesModule } from '../endpoints/asset-profiles/asset-profiles.module';
import { AssetController } from './asset.controller'; import { AssetController } from './asset.controller';
@Module({ @Module({

12
apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts

@ -6,7 +6,7 @@ import { ApiService } from '@ghostfolio/api/services/api/api.service';
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service';
import { UpdateAssetProfileDataDto } from '@ghostfolio/common/dtos'; import { UpdateAssetProfileDataDto } from '@ghostfolio/common/dtos';
import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper'; import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper';
import { MarketDataDetailsResponse } from '@ghostfolio/common/interfaces'; import { AssetProfileResponse } from '@ghostfolio/common/interfaces';
import { import {
AssetProfilesResponse, AssetProfilesResponse,
EnhancedSymbolProfile EnhancedSymbolProfile
@ -39,8 +39,8 @@ export class AssetProfilesController {
public constructor( public constructor(
private readonly apiService: ApiService, private readonly apiService: ApiService,
private readonly assetProfilesService: AssetProfilesService, private readonly assetProfilesService: AssetProfilesService,
private readonly symbolProfileService: SymbolProfileService, @Inject(REQUEST) private readonly request: RequestWithUser,
@Inject(REQUEST) private readonly request: RequestWithUser private readonly symbolProfileService: SymbolProfileService
) {} ) {}
@Get() @Get()
@ -76,10 +76,10 @@ export class AssetProfilesController {
@UseGuards(AuthGuard('jwt')) @UseGuards(AuthGuard('jwt'))
@UseInterceptors(TransformDataSourceInRequestInterceptor) @UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor)
public async getAssetProfileMarketData( public async getAssetProfile(
@Param('dataSource') dataSource: DataSource, @Param('dataSource') dataSource: DataSource,
@Param('symbol') symbol: string @Param('symbol') symbol: string
): Promise<MarketDataDetailsResponse> { ): Promise<AssetProfileResponse> {
const [assetProfile] = await this.symbolProfileService.getSymbolProfiles([ const [assetProfile] = await this.symbolProfileService.getSymbolProfiles([
{ dataSource, symbol } { dataSource, symbol }
]); ]);
@ -112,7 +112,7 @@ export class AssetProfilesController {
); );
} }
return this.assetProfilesService.getMarketDataBySymbol({ return this.assetProfilesService.getAssetProfile({
dataSource, dataSource,
symbol symbol
}); });

4
apps/api/src/app/endpoints/asset-profiles/asset-profiles.module.ts

@ -16,6 +16,7 @@ import { AssetProfilesService } from './asset-profiles.service';
@Module({ @Module({
controllers: [AssetProfilesController], controllers: [AssetProfilesController],
exports: [AssetProfilesService],
imports: [ imports: [
ActivitiesModule, ActivitiesModule,
ApiModule, ApiModule,
@ -28,7 +29,6 @@ import { AssetProfilesService } from './asset-profiles.service';
TransformDataSourceInRequestModule, TransformDataSourceInRequestModule,
TransformDataSourceInResponseModule TransformDataSourceInResponseModule
], ],
providers: [AssetProfilesService], providers: [AssetProfilesService]
exports: [AssetProfilesService]
}) })
export class AssetProfilesModule {} export class AssetProfilesModule {}

4
apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts

@ -31,14 +31,14 @@ export class AssetProfilesService {
public constructor( public constructor(
private readonly activitiesService: ActivitiesService, private readonly activitiesService: ActivitiesService,
private readonly benchmarkService: BenchmarkService, private readonly benchmarkService: BenchmarkService,
private readonly exchangeRateDataService: ExchangeRateDataService,
private readonly dataProviderService: DataProviderService, private readonly dataProviderService: DataProviderService,
private readonly exchangeRateDataService: ExchangeRateDataService,
private readonly marketDataService: MarketDataService, private readonly marketDataService: MarketDataService,
private readonly prismaService: PrismaService, private readonly prismaService: PrismaService,
private readonly symbolProfileService: SymbolProfileService private readonly symbolProfileService: SymbolProfileService
) {} ) {}
public async getMarketDataBySymbol({ public async getAssetProfile({
dataSource, dataSource,
symbol symbol
}: AssetProfileIdentifier): Promise<AdminMarketDataDetails> { }: AssetProfileIdentifier): Promise<AdminMarketDataDetails> {

4
libs/common/src/lib/interfaces/index.ts

@ -47,6 +47,7 @@ import type { AdminUsersResponse } from './responses/admin-users-response.interf
import type { AiPromptResponse } from './responses/ai-prompt-response.interface'; import type { AiPromptResponse } from './responses/ai-prompt-response.interface';
import type { AiServiceHealthResponse } from './responses/ai-service-health-response.interface'; import type { AiServiceHealthResponse } from './responses/ai-service-health-response.interface';
import type { ApiKeyResponse } from './responses/api-key-response.interface'; import type { ApiKeyResponse } from './responses/api-key-response.interface';
import type { AssetProfileResponse } from './responses/asset-profile-response.interface';
import type { AssetProfilesResponse } from './responses/asset-profiles-response.interface'; import type { AssetProfilesResponse } from './responses/asset-profiles-response.interface';
import type { AssetResponse } from './responses/asset-response.interface'; import type { AssetResponse } from './responses/asset-response.interface';
import type { BenchmarkMarketDataDetailsResponse } from './responses/benchmark-market-data-details-response.interface'; import type { BenchmarkMarketDataDetailsResponse } from './responses/benchmark-market-data-details-response.interface';
@ -67,7 +68,6 @@ import type { HistoricalResponse } from './responses/historical-response.interfa
import type { ImportResponse } from './responses/import-response.interface'; import type { ImportResponse } from './responses/import-response.interface';
import type { InfoResponse } from './responses/info-response.interface'; import type { InfoResponse } from './responses/info-response.interface';
import type { LookupResponse } from './responses/lookup-response.interface'; import type { LookupResponse } from './responses/lookup-response.interface';
import type { MarketDataDetailsResponse } from './responses/market-data-details-response.interface';
import type { MarketDataOfMarketsResponse } from './responses/market-data-of-markets-response.interface'; import type { MarketDataOfMarketsResponse } from './responses/market-data-of-markets-response.interface';
import type { OAuthResponse } from './responses/oauth-response.interface'; import type { OAuthResponse } from './responses/oauth-response.interface';
import type { PlatformsResponse } from './responses/platforms-response.interface'; import type { PlatformsResponse } from './responses/platforms-response.interface';
@ -123,6 +123,7 @@ export {
AssetClassSelectorOption, AssetClassSelectorOption,
AssetProfileIdentifier, AssetProfileIdentifier,
AssetProfileItem, AssetProfileItem,
AssetProfileResponse,
AssetProfilesResponse, AssetProfilesResponse,
AssetResponse, AssetResponse,
AttestationCredentialJSON, AttestationCredentialJSON,
@ -158,7 +159,6 @@ export {
LookupItem, LookupItem,
LookupResponse, LookupResponse,
MarketData, MarketData,
MarketDataDetailsResponse,
MarketDataOfMarketsResponse, MarketDataOfMarketsResponse,
NullableLineChartItem, NullableLineChartItem,
OAuthResponse, OAuthResponse,

2
libs/common/src/lib/interfaces/responses/market-data-details-response.interface.ts → libs/common/src/lib/interfaces/responses/asset-profile-response.interface.ts

@ -2,7 +2,7 @@ import { MarketData } from '@prisma/client';
import { EnhancedSymbolProfile } from '../enhanced-symbol-profile.interface'; import { EnhancedSymbolProfile } from '../enhanced-symbol-profile.interface';
export interface MarketDataDetailsResponse { export interface AssetProfileResponse {
assetProfile: Partial<EnhancedSymbolProfile>; assetProfile: Partial<EnhancedSymbolProfile>;
marketData: MarketData[]; marketData: MarketData[];
} }

4
libs/ui/src/lib/services/data.service.ts

@ -40,7 +40,7 @@ import {
ImportResponse, ImportResponse,
InfoItem, InfoItem,
LookupResponse, LookupResponse,
MarketDataDetailsResponse, AssetProfileResponse,
MarketDataOfMarketsResponse, MarketDataOfMarketsResponse,
OAuthResponse, OAuthResponse,
PlatformsResponse, PlatformsResponse,
@ -544,7 +544,7 @@ export class DataService {
}: { }: {
dataSource: DataSource; dataSource: DataSource;
symbol: string; symbol: string;
}): Observable<MarketDataDetailsResponse> { }): Observable<AssetProfileResponse> {
return this.http return this.http
.get<any>(`/api/v1/asset-profiles/${dataSource}/${symbol}`) .get<any>(`/api/v1/asset-profiles/${dataSource}/${symbol}`)
.pipe( .pipe(

Loading…
Cancel
Save