11import {
22 QueryExecutor ,
33 RubyGemsPackageToSync ,
4+ getOrCreateRepoByUrl ,
45 listRubyGemsPackagesToSync ,
56 logAuditFieldChange ,
67 recordDownloadSnapshot ,
78 upsertPackage ,
9+ upsertPackageRepo ,
810} from '@crowd/data-access-layer'
911import { getServiceChildLogger } from '@crowd/logging'
1012
@@ -106,6 +108,7 @@ async function processPackage(
106108 description : normalized . description ,
107109 homepage : normalized . homepage ,
108110 declaredRepositoryUrl : normalized . declaredRepositoryUrl ,
111+ repositoryUrl : normalized . repo ?. url ?? null ,
109112 licenses : normalized . licenses ,
110113 licensesRaw : normalized . licensesRaw ,
111114 latestVersion : normalized . latestVersion ,
@@ -114,6 +117,24 @@ async function processPackage(
114117 } )
115118 pkgChanged . forEach ( ( f ) => changed . add ( f ) )
116119
120+ if ( normalized . repo ) {
121+ const { id : repoId , changedFields : repoChanged } = await getOrCreateRepoByUrl (
122+ t ,
123+ normalized . repo . url ,
124+ normalized . repo . host ,
125+ )
126+ repoChanged . forEach ( ( f ) => changed . add ( f ) )
127+
128+ const linkChanged = await upsertPackageRepo (
129+ t ,
130+ packageDbId . toString ( ) ,
131+ repoId ,
132+ 'declared' ,
133+ 0.8 ,
134+ )
135+ linkChanged . forEach ( ( f ) => changed . add ( f ) )
136+ }
137+
117138 if ( normalized . totalDownloads > 0 ) {
118139 const dlChanged = await recordDownloadSnapshot ( t , {
119140 packageId : packageDbId ,
0 commit comments