Skip to content

Commit

Permalink
chore: Remove securities mocks from .gitignore & optimize their size
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha committed Apr 8, 2024
1 parent 881edee commit 2da0b5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,3 @@ dist

# TernJS port file
.tern-port

# Mocks
src/services/investments/mocks/*
1 change: 1 addition & 0 deletions src/services/investments/mocks/tickers-mock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/services/investments/mocks/tickers-prices-mock.json

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions src/services/investments/securities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import chunk from 'lodash/chunk';
import { marketDataService, type TickersResponse } from './market-data.service';

import tickersMock from './mocks/tickers-mock.json';
// import type { IAggs } from '@polygon.io/client-js';
// import tickersPricesMock from './mocks/tickers-prices-mock.json';
import type { IAggs } from '@polygon.io/client-js';
import tickersPricesMock from './mocks/tickers-prices-mock.json';

export async function loadSecuritiesList<T extends keyof SecurityAttributes>(
{ attributes }: { attributes?: T[] } = {},
Expand Down Expand Up @@ -60,8 +60,12 @@ export const syncSecuritiesList = async ({
`Started syncing stock tickers. ${startProfiling.toISOString()}`,
);

// const tickers = await marketDataService.getUSStockTickers();
const tickers = tickersMock as TickersResponse;
let tickers: TickersResponse = [];
if (process.env.NODE_ENV === 'production') {
tickers = await marketDataService.getUSStockTickers();
} else {
tickers = tickersMock as TickersResponse;
}

const endProfiling = new Date();

Expand Down Expand Up @@ -133,8 +137,13 @@ export const syncSecuritiesPricing = async ({
transaction = transaction ?? (await connection.sequelize.transaction());

try {
const dailyPrices = await marketDataService.getAllDailyPricing();
// const dailyPrices = tickersPricesMock as unknown as IAggs;
let dailyPrices: IAggs;

if (process.env.NODE_ENV === 'production') {
dailyPrices = await marketDataService.getAllDailyPricing();
} else {
dailyPrices = tickersPricesMock as unknown as IAggs;
}

const securities = await loadSecuritiesList(
{ attributes: ['assetClass', 'id', 'symbol', 'currencyCode'] },
Expand Down

0 comments on commit 2da0b5b

Please sign in to comment.