Skip to content

Commit

Permalink
fix: remove create timeline limitation (#801)
Browse files Browse the repository at this point in the history
* fix: update polkadot extension

* fix: remove create timeline limitation
  • Loading branch information
abdulhakim2902 authored Mar 4, 2023
1 parent 5dab00c commit 2ba4301
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 358 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@loopback/rest-explorer": "^5.0.4",
"@loopback/security": "^0.8.4",
"@loopback/service-proxy": "^5.0.4",
"@polkadot/api": "^9.9.1",
"@polkadot/api": "^9.14.2",
"@sentry/node": "^7.20.0",
"a-nonce-generator": "^2.0.1",
"ansi-colors": "^4.1.3",
Expand Down
18 changes: 0 additions & 18 deletions src/__tests__/acceptance/user-experience.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,6 @@ describe('UserExperienceApplication', function () {
.send(experience)
.expect(422);
});

it('rejects creates new experience when user has experience more than 10', async () => {
await userRepository.updateById(user.id.toString(), {fullAccess: true});

for (let i = 0; i < 10; i++) {
await givenExperienceInstance(experienceRepository, {
createdBy: user.id,
});
}

const experience = givenExperience({createdBy: user.id});

await client
.post(`/user/experiences`)
.set('Authorization', `Bearer ${token}`)
.send(experience)
.expect(422);
});
});

it('includes both user and experience in query result', async () => {
Expand Down
12 changes: 2 additions & 10 deletions src/services/user-experience.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class UserExperienceService {
): Promise<Experience> {
const userId = experience.createdBy;
const people = this.validateExperienceData(experience);
const totalExperience = await this.validateCreatedExperience(userId);
const totalExperience = await this.countUserExperience(userId);

if (experience.visibility !== VisibilityType.SELECTED) {
experience.selectedUserIds = [];
Expand Down Expand Up @@ -461,15 +461,7 @@ export class UserExperienceService {
);
}

private async validateCreatedExperience(userId: string): Promise<number> {
// Check if user has experiences less than equal 10
const createdBy = userId;
const {count} = await this.experienceRepository.count({createdBy});

if (count >= 10) {
throw new HttpErrors.UnprocessableEntity('ExperiencesExceeded');
}

private async countUserExperience(userId: string): Promise<number> {
const {count: total} = await this.userExperienceRepository.count({userId});
return total;
}
Expand Down
Loading

0 comments on commit 2ba4301

Please sign in to comment.