Release/1.71.0 (#458)
* Refactor logger * Fix exception * Update changelog
This commit is contained in:
parent
2873130259
commit
d60b444324
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@ -26,7 +26,8 @@
|
||||
"skipFiles": [
|
||||
"${workspaceFolder}/node_modules/**/*.js",
|
||||
"<node_internals>/**/*.js"
|
||||
]
|
||||
],
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 1.71.0 - 07.11.2021
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed the logger from `console.log()` to `Logger.log()`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an exception in the scraper configuration
|
||||
|
||||
## 1.70.0 - 07.11.2021
|
||||
|
||||
### Changed
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Provider } from '@prisma/client';
|
||||
import { Strategy } from 'passport-google-oauth20';
|
||||
@ -41,9 +41,9 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||
};
|
||||
|
||||
done(null, user);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
done(err, false);
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
done(error, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import type { RequestWithUser } from '@ghostfolio/common/types';
|
||||
import {
|
||||
Inject,
|
||||
Injectable,
|
||||
InternalServerErrorException
|
||||
InternalServerErrorException,
|
||||
Logger
|
||||
} from '@nestjs/common';
|
||||
import { REQUEST } from '@nestjs/core';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
@ -94,7 +95,7 @@ export class WebAuthService {
|
||||
};
|
||||
verification = await verifyRegistrationResponse(opts);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
throw new InternalServerErrorException(error.message);
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ export class WebAuthService {
|
||||
};
|
||||
verification = verifyAuthenticationResponse(opts);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
throw new InternalServerErrorException({ error: error.message });
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import {
|
||||
Controller,
|
||||
HttpException,
|
||||
Inject,
|
||||
Logger,
|
||||
Post,
|
||||
UseGuards
|
||||
} from '@nestjs/common';
|
||||
@ -39,7 +40,7 @@ export class ImportController {
|
||||
userId: this.request.user.id
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
throw new HttpException(
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||
import { InfoItem } from '@ghostfolio/common/interfaces';
|
||||
import { Subscription } from '@ghostfolio/common/interfaces/subscription.interface';
|
||||
import { permissions } from '@ghostfolio/common/permissions';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import * as bent from 'bent';
|
||||
import { subDays } from 'date-fns';
|
||||
@ -109,7 +109,7 @@ export class InfoService {
|
||||
const contributors = await get();
|
||||
return contributors?.length;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@ -130,7 +130,7 @@ export class InfoService {
|
||||
const { stargazers_count } = await get();
|
||||
return stargazers_count;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import { OrderType } from '@ghostfolio/api/models/order-type';
|
||||
import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces';
|
||||
import { DATE_FORMAT, parseDate, resetHours } from '@ghostfolio/common/helper';
|
||||
import { TimelinePosition } from '@ghostfolio/common/interfaces';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import Big from 'big.js';
|
||||
import {
|
||||
addDays,
|
||||
@ -236,7 +237,7 @@ export class PortfolioCalculator {
|
||||
if (!marketSymbolMap[nextDate]?.[item.symbol]) {
|
||||
invalidSymbols.push(item.symbol);
|
||||
hasErrors = true;
|
||||
console.error(
|
||||
Logger.error(
|
||||
`Missing value for symbol ${item.symbol} at ${nextDate}`
|
||||
);
|
||||
continue;
|
||||
@ -269,7 +270,7 @@ export class PortfolioCalculator {
|
||||
if (!initialValue) {
|
||||
invalidSymbols.push(item.symbol);
|
||||
hasErrors = true;
|
||||
console.error(
|
||||
Logger.error(
|
||||
`Missing value for symbol ${item.symbol} at ${currentDate}`
|
||||
);
|
||||
continue;
|
||||
@ -480,7 +481,7 @@ export class PortfolioCalculator {
|
||||
currentPosition.netPerformancePercentage.mul(currentInitialValue)
|
||||
);
|
||||
} else if (!currentPosition.quantity.eq(0)) {
|
||||
console.error(
|
||||
Logger.error(
|
||||
`Initial value is missing for symbol ${currentPosition.symbol}`
|
||||
);
|
||||
hasErrors = true;
|
||||
@ -546,7 +547,7 @@ export class PortfolioCalculator {
|
||||
userCurrency: this.currency
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(
|
||||
Logger.error(
|
||||
`Failed to fetch info for date ${startDate} with exception`,
|
||||
error
|
||||
);
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
Get,
|
||||
HttpException,
|
||||
Inject,
|
||||
Logger,
|
||||
Post,
|
||||
Req,
|
||||
Res,
|
||||
@ -46,7 +47,7 @@ export class SubscriptionController {
|
||||
userId: this.request.user.id
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
throw new HttpException(
|
||||
getReasonPhrase(StatusCodes.BAD_REQUEST),
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||
import { SubscriptionType } from '@ghostfolio/common/types/subscription.type';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Subscription } from '@prisma/client';
|
||||
import { addDays, isBefore } from 'date-fns';
|
||||
import Stripe from 'stripe';
|
||||
@ -85,7 +85,7 @@ export class SubscriptionService {
|
||||
description: session.client_reference_id
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
||||
import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces';
|
||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
|
||||
import { LookupItem } from './interfaces/lookup-item.interface';
|
||||
@ -67,7 +67,7 @@ export class SymbolService {
|
||||
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
ghostfolioFearAndGreedIndexSymbol
|
||||
} from '@ghostfolio/common/config';
|
||||
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
import {
|
||||
differenceInHours,
|
||||
@ -41,7 +41,7 @@ export class DataGatheringService {
|
||||
const isDataGatheringNeeded = await this.isDataGatheringNeeded();
|
||||
|
||||
if (isDataGatheringNeeded) {
|
||||
console.log('7d data gathering has been started.');
|
||||
Logger.log('7d data gathering has been started.');
|
||||
console.time('data-gathering-7d');
|
||||
|
||||
await this.prismaService.property.create({
|
||||
@ -65,7 +65,7 @@ export class DataGatheringService {
|
||||
where: { key: 'LAST_DATA_GATHERING' }
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
await this.prismaService.property.delete({
|
||||
@ -74,7 +74,7 @@ export class DataGatheringService {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('7d data gathering has been completed.');
|
||||
Logger.log('7d data gathering has been completed.');
|
||||
console.timeEnd('data-gathering-7d');
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ export class DataGatheringService {
|
||||
});
|
||||
|
||||
if (!isDataGatheringLocked) {
|
||||
console.log('Max data gathering has been started.');
|
||||
Logger.log('Max data gathering has been started.');
|
||||
console.time('data-gathering-max');
|
||||
|
||||
await this.prismaService.property.create({
|
||||
@ -109,7 +109,7 @@ export class DataGatheringService {
|
||||
where: { key: 'LAST_DATA_GATHERING' }
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
await this.prismaService.property.delete({
|
||||
@ -118,13 +118,13 @@ export class DataGatheringService {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Max data gathering has been completed.');
|
||||
Logger.log('Max data gathering has been completed.');
|
||||
console.timeEnd('data-gathering-max');
|
||||
}
|
||||
}
|
||||
|
||||
public async gatherProfileData(aDataGatheringItems?: IDataGatheringItem[]) {
|
||||
console.log('Profile data gathering has been started.');
|
||||
Logger.log('Profile data gathering has been started.');
|
||||
console.time('data-gathering-profile');
|
||||
|
||||
let dataGatheringItems = aDataGatheringItems;
|
||||
@ -152,7 +152,7 @@ export class DataGatheringService {
|
||||
symbol: symbolMapping[dataEnhancer.getName()] ?? symbol
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Failed to enhance data for symbol ${symbol}`, error);
|
||||
Logger.error(`Failed to enhance data for symbol ${symbol}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,11 +194,11 @@ export class DataGatheringService {
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`${symbol}: ${error?.meta?.cause}`);
|
||||
Logger.error(`${symbol}: ${error?.meta?.cause}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Profile data gathering has been completed.');
|
||||
Logger.log('Profile data gathering has been completed.');
|
||||
console.timeEnd('data-gathering-profile');
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ export class DataGatheringService {
|
||||
}
|
||||
} catch (error) {
|
||||
hasError = true;
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ export class DataGatheringService {
|
||||
}
|
||||
|
||||
public async reset() {
|
||||
console.log('Data gathering has been reset.');
|
||||
Logger.log('Data gathering has been reset.');
|
||||
|
||||
await this.prismaService.property.deleteMany({
|
||||
where: {
|
||||
|
@ -2,7 +2,7 @@ import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.in
|
||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
||||
import { Granularity } from '@ghostfolio/common/types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
import { isAfter, isBefore, parse } from 'date-fns';
|
||||
|
||||
@ -78,7 +78,7 @@ export class AlphaVantageService implements DataProviderInterface {
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error(error, symbol);
|
||||
Logger.error(error, symbol);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
||||
import { Granularity } from '@ghostfolio/common/types';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource, MarketData } from '@prisma/client';
|
||||
import { format } from 'date-fns';
|
||||
import { isEmpty } from 'lodash';
|
||||
@ -109,7 +109,7 @@ export class DataProviderService {
|
||||
return r;
|
||||
}, {});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
} finally {
|
||||
return response;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
isGhostfolioScraperApiSymbol
|
||||
} from '@ghostfolio/common/helper';
|
||||
import { Granularity } from '@ghostfolio/common/types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
import * as bent from 'bent';
|
||||
import * as cheerio from 'cheerio';
|
||||
@ -64,7 +64,7 @@ export class GhostfolioScraperApiService implements DataProviderInterface {
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
return {};
|
||||
@ -106,7 +106,7 @@ export class GhostfolioScraperApiService implements DataProviderInterface {
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
isRakutenRapidApiSymbol
|
||||
} from '@ghostfolio/common/helper';
|
||||
import { Granularity } from '@ghostfolio/common/types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
import * as bent from 'bent';
|
||||
import { format, subMonths, subWeeks, subYears } from 'date-fns';
|
||||
@ -61,7 +61,7 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
return {};
|
||||
@ -166,7 +166,7 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
||||
const { fgi } = await get();
|
||||
return fgi;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/c
|
||||
import { UNKNOWN_KEY } from '@ghostfolio/common/config';
|
||||
import { DATE_FORMAT, isCurrency } from '@ghostfolio/common/helper';
|
||||
import { Granularity } from '@ghostfolio/common/types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { AssetClass, AssetSubClass, DataSource } from '@prisma/client';
|
||||
import * as bent from 'bent';
|
||||
import Big from 'big.js';
|
||||
@ -117,7 +117,7 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -169,7 +169,7 @@ export class YahooFinanceService implements DataProviderInterface {
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Logger.error(error);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { baseCurrency } from '@ghostfolio/common/config';
|
||||
import { DATE_FORMAT, getYesterday } from '@ghostfolio/common/helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource } from '@prisma/client';
|
||||
import { format } from 'date-fns';
|
||||
import { isEmpty, isNumber, uniq } from 'lodash';
|
||||
@ -140,7 +140,7 @@ export class ExchangeRateDataService {
|
||||
}
|
||||
|
||||
// Fallback with error, if currencies are not available
|
||||
console.error(
|
||||
Logger.error(
|
||||
`No exchange rate has been found for ${aFromCurrency}${aToCurrency}`
|
||||
);
|
||||
return aValue;
|
||||
|
@ -12,7 +12,7 @@ export interface EnhancedSymbolProfile {
|
||||
dataSource: DataSource;
|
||||
id: string;
|
||||
name: string | null;
|
||||
scraperConfiguration?: ScraperConfiguration;
|
||||
scraperConfiguration?: ScraperConfiguration | null;
|
||||
sectors: Sector[];
|
||||
symbol: string;
|
||||
symbolMapping?: { [key: string]: string };
|
||||
|
@ -59,10 +59,14 @@ export class SymbolProfileService {
|
||||
const scraperConfiguration =
|
||||
symbolProfile.scraperConfiguration as Prisma.JsonObject;
|
||||
|
||||
return {
|
||||
selector: scraperConfiguration.selector as string,
|
||||
url: scraperConfiguration.url as string
|
||||
};
|
||||
if (scraperConfiguration) {
|
||||
return {
|
||||
selector: scraperConfiguration.selector as string,
|
||||
url: scraperConfiguration.url as string
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private getSectors(symbolProfile: SymbolProfile): Sector[] {
|
||||
|
@ -29,5 +29,5 @@ import { environment } from './environments/environment';
|
||||
.bootstrapModule(AppModule, {
|
||||
providers: [{ provide: LOCALE_ID, useValue: 'de-CH' }]
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
.catch((error) => console.error(error));
|
||||
})();
|
||||
|
Loading…
x
Reference in New Issue
Block a user