Skip to content

Commit

Permalink
fix: get the info about user only once as it is always the same
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Nov 22, 2019
1 parent 2b67091 commit f54425d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ export class BitbucketService implements ICVSService {

const response = <DeepRequired<Bitbucket.Response<Bitbucket.Schema.PaginatedPullrequests>>>await this.client.pullrequests.list(params);
const url = 'www.bitbucket.org';
const ownerId = <string>(await this.client.users.get({ username: owner })).data.uuid;
const urlOwner = url.concat(`/${owner}`);

const values = response.data.values.map(async (val) => {
const ownerId = <string>(
(await this.client.users.get({ username: `${val.destination.repository.full_name.split('/').shift()}` })).data.uuid
);
return {
user: {
id: val.author.uuid,
Expand All @@ -122,9 +121,9 @@ export class BitbucketService implements ICVSService {
name: val.destination.repository.name,
id: val.destination.repository.uuid,
owner: {
login: <string>val.destination.repository.full_name.split('/').shift(),
id: ownerId ? ownerId : 'undefined',
url: url.concat(`/${val.destination.repository.full_name.split('/').shift()}`),
login: owner,
id: ownerId,
url: urlOwner,
},
},
},
Expand Down

0 comments on commit f54425d

Please sign in to comment.