Skip to content

Commit

Permalink
Limit company metrics (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorgomezv authored Oct 12, 2023
1 parent b60e571 commit d251ef9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/companies/repositories/company-states.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable, Logger } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { plainToInstance } from 'class-transformer';
import { sub } from 'date-fns';
import { Model } from 'mongoose';
import { from } from '../../common/cache/cache.key.mapper';
import { RedisClient } from '../../common/cache/redis.client';
Expand Down Expand Up @@ -106,11 +107,15 @@ export class CompanyStatesRepository {
return result;
}

/**
* Gets {@link CompanyMetrics} for the last year.
*/
async getMetricsByCompanyUuid(companyUuid: string): Promise<CompanyMetrics> {
const metrics = await this.model
.aggregate()
.match({
companyUuid,
timestamp: { $gte: sub(new Date(), { years: 1 }) },
enterpriseToRevenue: { $ne: NaN },
enterpriseToEbitda: { $ne: NaN },
peg: { $ne: NaN },
Expand Down
2 changes: 1 addition & 1 deletion src/portfolios/__tests__/portfolios.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Portfolios e2e tests', () => {
});
});

it.only('/POST portfolio, company and two positions', async () => {
it('/POST portfolio, company and two positions', async () => {
await request(app.getHttpServer())
.post('/portfolios')
.set('Authorization', `Bearer ${accessToken}`)
Expand Down

0 comments on commit d251ef9

Please sign in to comment.