@@ -24,13 +24,9 @@ import { ResourceNotFoundException } from "../../errors/exceptions/resource-not-
2424import { SweetQueue , addJob } from "../../../bull-mq/queues" ;
2525import { findWorkspaceByGitInstallationId } from "../../workspaces/services/workspace.service" ;
2626import { parseISO } from "date-fns" ;
27-
28- interface Author {
29- id : string ;
30- login : string ;
31- name : string ;
32- avatarUrl : string ;
33- }
27+ import { upsertGitProfile } from "../../gitProfile/services/git-profile.service" ;
28+ import { GitHubUser } from "./github-user.types" ;
29+ import { gitHubUserToGitProfileData } from "./github-user.service" ;
3430
3531interface ReviewData {
3632 gitProfileId : number ;
@@ -46,7 +42,7 @@ type ReviewDataWithId = ReviewData & {
4642interface ReviewRequestData {
4743 createdAt : Date ;
4844 deletedAt : Date | null ;
49- author : Author ;
45+ author : GitHubUser ;
5046}
5147
5248export const syncCodeReviews = async (
@@ -131,13 +127,16 @@ const fetchPullRequestReviews = async (
131127 const reviewEvents : ReviewDataWithId [ ] = [ ] ;
132128 const gitProfiles = new Map < string , GitProfile > ( ) ;
133129
134- const getGitProfileId = async ( author : Author ) => {
135- if ( gitProfiles . has ( author . id ) ) {
136- return gitProfiles . get ( author . id ) ! . id ;
130+ const getGitProfileId = async ( author : GitHubUser ) => {
131+ if ( gitProfiles . has ( author . nodeId ) ) {
132+ return gitProfiles . get ( author . nodeId ) ! . id ;
137133 }
138134
139- const gitProfile = await upsertGitProfile ( author ) ;
140- gitProfiles . set ( author . id , gitProfile ) ;
135+ const gitProfile = await upsertGitProfile (
136+ gitHubUserToGitProfileData ( author )
137+ ) ;
138+
139+ gitProfiles . set ( author . nodeId , gitProfile ) ;
141140
142141 return gitProfile . id ;
143142 } ;
@@ -154,6 +153,8 @@ const fetchPullRequestReviews = async (
154153 login
155154 name
156155 avatarUrl
156+ bio
157+ location
157158 }
158159 }
159160 }
@@ -166,6 +167,8 @@ const fetchPullRequestReviews = async (
166167 login
167168 name
168169 avatarUrl
170+ bio
171+ location
169172 }
170173 }
171174 }
@@ -201,6 +204,8 @@ const fetchPullRequestReviews = async (
201204 login
202205 name
203206 avatarUrl
207+ bio
208+ location
204209 }
205210 }
206211 comments {
@@ -336,10 +341,12 @@ const getReviewRequests = (nodes: any[]): ReviewRequestData[] => {
336341 createdAt : new Date ( node . createdAt ) ,
337342 deletedAt : null ,
338343 author : {
339- id : reviewerId ,
344+ nodeId : reviewerId ,
340345 login : node . requestedReviewer . login ,
341346 name : node . requestedReviewer . name ,
342347 avatarUrl : node . requestedReviewer . avatarUrl ,
348+ bio : node . requestedReviewer . bio ,
349+ location : node . requestedReviewer . location ,
343350 } ,
344351 } ) ;
345352 }
@@ -356,10 +363,12 @@ const getReviewRequests = (nodes: any[]): ReviewRequestData[] => {
356363 if ( reviewRequest ) {
357364 reviewRequest . deletedAt = new Date ( node . createdAt ) ;
358365 reviewRequest . author = {
359- id : reviewerId ,
366+ nodeId : reviewerId ,
360367 login : node . requestedReviewer . login ,
361368 name : node . requestedReviewer . name ,
362369 avatarUrl : node . requestedReviewer . avatarUrl ,
370+ bio : node . requestedReviewer . bio ,
371+ location : node . requestedReviewer . location ,
363372 } ;
364373 }
365374 }
@@ -376,7 +385,9 @@ const upsertCodeReviewRequests = async (
376385 logger . debug ( "upsertCodeReviewRequests" , { pullRequest, reviewRequests } ) ;
377386
378387 return parallel ( 10 , reviewRequests , async ( reviewRequest ) => {
379- const gitProfile = await upsertGitProfile ( reviewRequest . author ) ;
388+ const gitProfile = await upsertGitProfile (
389+ gitHubUserToGitProfileData ( reviewRequest . author )
390+ ) ;
380391
381392 const data = {
382393 workspaceId : pullRequest . workspaceId ,
@@ -481,25 +492,6 @@ const updatePullRequestTracking = async (
481492 } ) ;
482493} ;
483494
484- const upsertGitProfile = async ( author : Author ) => {
485- return getPrisma ( ) . gitProfile . upsert ( {
486- where : {
487- gitProvider_gitUserId : {
488- gitProvider : GitProvider . GITHUB ,
489- gitUserId : author . id ,
490- } ,
491- } ,
492- update : { } ,
493- create : {
494- gitProvider : GitProvider . GITHUB ,
495- gitUserId : author . id ,
496- handle : author . login ,
497- name : author . name ? author . name : author . login ,
498- avatar : author . avatarUrl ,
499- } ,
500- } ) ;
501- } ;
502-
503495const findPullRequest = async (
504496 workspaceId : number ,
505497 gitPullRequestId : string
0 commit comments