style: align multiline ternary operators
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Failing after 2m11s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 2m17s
Conventional commits / commits (pull_request) Successful in 34s

This commit is contained in:
2026-09-28 12:33:56 +03:00
parent 9cc9fbdcff
commit 0303e60b64
54 changed files with 986 additions and 982 deletions
@@ -36,8 +36,8 @@ export class ForecastService {
...input,
portfolioProjection: input.portfolio.dataRevision,
portfolios: (input.portfolio.dependencies ?? []).flatMap((dependency) =>
dependency.resourceKey.startsWith('portfolio/') ?
[
dependency.resourceKey.startsWith('portfolio/')
? [
{
accountId: decodeURIComponent(
dependency.resourceKey.slice('portfolio/'.length),
@@ -46,21 +46,21 @@ export class ForecastService {
(dependency as InvestmentResourceMetaDto).dataRevision,
),
},
] :
[],
]
: [],
),
sources: input.sources.flatMap((source) =>
source.version ? [source.version] : [],
),
timestamps: dependencies.flatMap((dependency) =>
dependency.lastSuccessfulAt ?
[
dependency.lastSuccessfulAt
? [
{
resourceKey: dependency.resourceKey,
at: dependency.lastSuccessfulAt,
},
] :
[],
]
: [],
),
});
const timestamps = stored?.sourceTimestamps as
@@ -78,33 +78,33 @@ export class ForecastService {
payload &&
'positionIsStale' in payload &&
'positionAt' in payload &&
typeof payload.positionAt === 'string' ?
{
typeof payload.positionAt === 'string'
? {
...payload,
positionIsStale: tbankSourceNeedsRefresh(
'portfolio',
new Date(payload.positionAt),
new Date(Date.now()),
),
} :
payload;
}
: payload;
return {
data,
meta: investmentResourceMeta({
resourceKey: input.scopeKey,
dataRevision: String(stored?.dataRevision ?? MISSING_DATA_REVISION),
availability: stored ?
'complete' :
dependencies.some(
availability: stored
? 'complete'
: dependencies.some(
(dependency) => dependency.availability !== 'missing',
) ?
'partial' :
'missing',
)
? 'partial'
: 'missing',
fetchedAt: first ? new Date(first) : null,
freshForMs:
data && 'positionIsStale' in data && data.positionIsStale === true ?
STALE_FRESHNESS_MS :
Number.POSITIVE_INFINITY,
data && 'positionIsStale' in data && data.positionIsStale === true
? STALE_FRESHNESS_MS
: Number.POSITIVE_INFINITY,
work: work?.id ? { ...work, id: work.id } : null,
dependencies,
}),
@@ -186,15 +186,15 @@ export class PortfolioService {
name: account.name,
type: account.type,
openedOn: account.openedOn,
snapshot: account.portfolio ?
{
snapshot: account.portfolio
? {
...(account.portfolio.payload as unknown as PortfolioDto),
lastSuccessfulAt: account.portfolio.fetchedAt.toISOString(),
isStale:
Date.now() - account.portfolio.fetchedAt.valueOf() >=
portfolioFreshForMs,
} :
null,
}
: null,
meta: investmentResourceMeta({
resourceKey: `portfolio/${encodeURIComponent(account.accountId)}`,
dataRevision: String(account.portfolio?.dataRevision ?? MISSING_DATA_REVISION),
@@ -220,8 +220,8 @@ export class PortfolioService {
);
const metadataDependencies = [...metadata.entries()].flatMap(
([key, source]) =>
source.complete && source.data ?
[
source.complete && source.data
? [
investmentResourceMeta({
resourceKey: `instrument/metadata/${key}`,
dataRevision: source.dataRevision,
@@ -230,20 +230,20 @@ export class PortfolioService {
freshForMs: tbankSourceTtlMs.metadata,
work: null,
}),
] :
[],
]
: [],
);
const portfolios = saved.accounts.flatMap((account) =>
account.snapshot ?
[
account.snapshot
? [
{
...account.snapshot,
positions: account.snapshot.positions.map((position) => {
const shared = metadata.get(metadataKey(position))?.data;
return {
...position,
...(shared ?
{
...(shared
? {
displayName:
shared.name?.trim() ||
shared.ticker?.trim() ||
@@ -252,29 +252,29 @@ export class PortfolioService {
isin: shared.isin?.trim() || position.isin,
logoName:
shared.brand?.logoName?.trim() || position.logoName,
} :
{}),
...(accountId === 'all' ?
{ account: { id: account.id, name: account.name } } :
{}),
}
: {}),
...(accountId === 'all'
? { account: { id: account.id, name: account.name } }
: {}),
};
}),
},
] :
[],
]
: [],
);
const lastSuccessfulAt =
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- Code-unit ordering is intentional for canonical keys and ISO dates; locale collation would change persisted bindings.
portfolios.map((portfolio) => portfolio.lastSuccessfulAt).sort()[0] ??
saved.membership.lastSuccessfulAt;
const data =
missing || !lastSuccessfulAt ?
null :
{
missing || !lastSuccessfulAt
? null
: {
lastSuccessfulAt,
isStale: portfolios.length ?
portfolios.some((portfolio) => portfolio.isStale) :
saved.membership.freshness !== 'fresh',
isStale: portfolios.length
? portfolios.some((portfolio) => portfolio.isStale)
: saved.membership.freshness !== 'fresh',
totalsByCurrency: sumMoneyByCurrency(
portfolios.flatMap((portfolio) => portfolio.totalsByCurrency),
),
@@ -306,15 +306,15 @@ export class PortfolioService {
]),
metadataDependencies.map((dependency) => dependency.dataRevision),
]),
availability: missing ?
portfolios.length ?
'partial' :
'missing' :
'complete',
availability: missing
? portfolios.length
? 'partial'
: 'missing'
: 'complete',
fetchedAt: lastSuccessfulAt ? new Date(lastSuccessfulAt) : null,
freshForMs: portfolios.length ?
portfolioFreshForMs :
membershipFreshForMs,
freshForMs: portfolios.length
? portfolioFreshForMs
: membershipFreshForMs,
work: work.id ? { ...work, id: work.id } : null,
dependencies: [
saved.membership,
@@ -478,8 +478,8 @@ export class PortfolioService {
const absoluteReturn =
currentPrice &&
averagePurchasePrice &&
currentPrice.currency === averagePurchasePrice.currency ?
{
currentPrice.currency === averagePurchasePrice.currency
? {
currency: currentPrice.currency,
value: formatDecimal(
multiply(
@@ -490,8 +490,8 @@ export class PortfolioService {
quantity,
),
),
} :
null;
}
: null;
return {
figi,
instrumentUid,
@@ -523,8 +523,8 @@ export class PortfolioService {
private money(value: TbankMoney | undefined): MoneyDto | null {
const currency = value?.currency?.trim().toUpperCase();
return currency && value ?
{ currency, value: formatDecimal(decimal(value)) } :
null;
return currency && value
? { currency, value: formatDecimal(decimal(value)) }
: null;
}
}
@@ -43,9 +43,9 @@ export function portfolioStructure(
currencies.set(money.currency, group);
};
for (const position of positions) {
const type = ['BOND', 'STOCK'].includes(position.type) ?
position.type :
'OTHER';
const type = ['BOND', 'STOCK'].includes(position.type)
? position.type
: 'OTHER';
if (position.currentValue) include(type, position.currentValue);
else unvalued.set(type, (unvalued.get(type) ?? INITIAL_UNVALUED_COUNT) + POSITION_INCREMENT);
}
@@ -65,8 +65,8 @@ export function portfolioStructure(
value: formatDecimal(value),
// Rounded to six decimal places using integer arithmetic. Only the
// resulting dimensionless percentage is passed to chart geometry.
sharePercent: canCalculateShares ?
formatDecimal({
sharePercent: canCalculateShares
? formatDecimal({
value:
(value.value *
DECIMAL_RADIX ** BigInt(total.scale - value.scale) *
@@ -74,8 +74,8 @@ export function portfolioStructure(
total.value / ROUNDING_DIVISOR) /
total.value,
scale: SHARE_PERCENT_DECIMAL_PLACES,
}) :
null,
})
: null,
}));
return {
currency,
@@ -58,9 +58,9 @@ export class ForecastRepository {
where: { userId_revision_scopeKey: key },
});
const fallback =
previous?.membershipRevision === input.membershipRevision ?
previous :
null;
previous?.membershipRevision === input.membershipRevision
? previous
: null;
if (!input.candidate) return fallback;
const portfolios = await tx.tbankPortfolio.findMany({
where: {