diff --git a/README.md b/README.md index 4d34facd9..eddb87c3e 100644 --- a/README.md +++ b/README.md @@ -13,67 +13,4 @@

A progressive Node.js framework for building efficient and scalable server-side applications.

-NPM Version -Package License -NPM Downloads -CircleCI -Coverage -Discord -Backers on Open Collective -Sponsors on Open Collective - - Support us - -

- - -## Description - -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. - -## Installation - -```bash -$ npm install -``` - -## Running the app - -```bash -# development -$ npm run start - -# watch mode -$ npm run start:dev - -# production mode -$ npm run start:prod -``` - -## Test - -```bash -# unit tests -$ npm run test - -# e2e tests -$ npm run test:e2e - -# test coverage -$ npm run test:cov -``` - -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch - -- Author - [Kamil Myƛliwiec](https://kamilmysliwiec.com) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) - -## License -Nest is [MIT licensed](LICENSE). diff --git a/src/features/family/family.controller.ts b/src/features/family/family.controller.ts index 96b05f6a4..d82a48941 100644 --- a/src/features/family/family.controller.ts +++ b/src/features/family/family.controller.ts @@ -198,7 +198,11 @@ export class FamilyController { }); // confirm duration - const confirmDuration = daysDifference(need.created, need.confirmDate); + let confirmDuration = daysDifference(need.created, need.confirmDate); + if (confirmDuration < 0) { + // some data from 2019 have wrong confirm dates, such as need 35 + confirmDuration = 0; + } const confirmsInRange = await this.needService.getConfirmsInRange( need.confirmDate, need.category, diff --git a/src/features/midjourney/midjourney.controller.ts b/src/features/midjourney/midjourney.controller.ts index 0f4bab0c4..afb631e59 100644 --- a/src/features/midjourney/midjourney.controller.ts +++ b/src/features/midjourney/midjourney.controller.ts @@ -115,11 +115,12 @@ export class MidjourneyController { const limit = X_LIMIT > 100 ? 100 : X_LIMIT; const page = X_TAKE + 1; const needsWithSignatures = - await this.midjourneyService.getReadyToSignNeeds({ + await this.midjourneyService.getOnlyReadyToMidjourney({ page: page, limit: limit, path: '', }); + const count = await this.midjourneyService.countAllNeedJourney(); const list = []; @@ -135,7 +136,11 @@ export class MidjourneyController { }); } }); - return { total: needsWithSignatures.meta.totalItems, list }; + return { + totalReady: needsWithSignatures.meta.totalItems, + total: count, + list, + }; } @ApiFileResponse('image/png') diff --git a/src/features/midjourney/midjourney.service.ts b/src/features/midjourney/midjourney.service.ts index 0c6b3de43..6f3ff026f 100644 --- a/src/features/midjourney/midjourney.service.ts +++ b/src/features/midjourney/midjourney.service.ts @@ -100,7 +100,7 @@ export class MidjourneyService { return await this.needService.getNeedByFlaskId(flaskNeedId); } - async getReadyToSignNeeds( + async getOnlyReadyToMidjourney( options: PaginateQuery, ): Promise> { const queryBuilder = this.needRepository @@ -125,7 +125,8 @@ export class MidjourneyService { ) .where('signature.role = :role', { role: SAYPlatformRoles.SOCIAL_WORKER, - }); + }) + .andWhere('need.midjourneyImage IS NULL'); return await nestPaginate(options, queryBuilder, { sortableColumns: ['id'], @@ -133,4 +134,31 @@ export class MidjourneyService { nullSort: 'last', }); } + + async countAllNeedJourney(): Promise { + return await this.needRepository + .createQueryBuilder('need') + .leftJoinAndMapOne( + 'need.ngo', + NgoEntity, + 'ngo', + 'ngo.flaskNgoId = need.flaskNgoId', + ) + .leftJoinAndMapMany( + 'need.verifiedPayments', + PaymentEntity, + 'verifiedPayments', + 'verifiedPayments.flaskNeedId = need.flaskId', + ) + .leftJoinAndMapMany( + 'need.signatures', + SignatureEntity, + 'signature', + 'signature.flaskNeedId = need.flaskId', + ) + .where('signature.role = :role', { + role: SAYPlatformRoles.SOCIAL_WORKER, + }) + .getCount(); + } }