@@ -12,35 +12,42 @@ namespace Algorithms {
1212 const res = await fetch ( `${ RC_APP_URI } /purgeDB` , {
1313 method : "POST" ,
1414 headers : {
15+ accept : "application/json" ,
1516 "Content-Type" : "application/json" ,
1617 } ,
1718 } )
1819
1920 return res . status === 200
2021 } catch ( e ) {
21- console . log ( e ) ;
22+ console . log ( e )
2223 return false
2324 }
2425 }
2526
26- export async function insertBatch ( batchID : string , nodes : DBNode [ ] ) : Promise < boolean > {
27+ export async function insertBatch (
28+ batchID : string ,
29+ nodes : DBNode [ ]
30+ ) : Promise < boolean > {
2731 try {
2832 const res = await fetch ( `${ RC_APP_URI } /ingest` , {
2933 method : "POST" ,
3034 headers : {
35+ accept : "application/json" ,
3136 "Content-Type" : "application/json" ,
3237 } ,
3338 body : JSON . stringify ( { nodes, batchID } ) ,
3439 } )
3540
3641 return res . status === 200
3742 } catch ( e ) {
38- console . log ( e ) ;
43+ console . log ( e )
3944 return false
4045 }
4146 }
4247
43- export async function establishRelations ( relations : DBNodeRelation [ ] ) : Promise < boolean > {
48+ export async function establishRelations (
49+ relations : DBNodeRelation [ ]
50+ ) : Promise < boolean > {
4451 try {
4552 const res = await fetch ( `${ RC_APP_URI } /establishRelations` , {
4653 method : "POST" ,
@@ -52,7 +59,7 @@ namespace Algorithms {
5259
5360 return res . status === 200
5461 } catch ( e ) {
55- console . log ( e ) ;
62+ console . log ( e )
5663 return false
5764 }
5865 }
@@ -87,11 +94,13 @@ export async function insertDataIntoDB(batchesDirPath: string) {
8794 const nodes = Object . values ( JSON . parse ( data ) ) as DBNode [ ]
8895
8996 for ( const node of nodes )
90- relations . push ( ...node . relations . map ( ( relation ) => ( {
91- source : node . id ,
92- target : relation . target ,
93- relation : relation . relation ,
94- } ) ) )
97+ relations . push (
98+ ...node . relations . map ( ( relation ) => ( {
99+ source : node . id ,
100+ target : relation . target ,
101+ relation : relation . relation ,
102+ } ) )
103+ )
95104
96105 const success = await Algorithms . insertBatch ( batchID , nodes )
97106 if ( success ) {
@@ -100,8 +109,7 @@ export async function insertDataIntoDB(batchesDirPath: string) {
100109 errorBatches . add ( batchID )
101110 }
102111 }
103- if ( errorBatches . size > 0 )
104- console . log ( "❌ Error batches" , errorBatches )
112+ if ( errorBatches . size > 0 ) console . log ( "❌ Error batches" , errorBatches )
105113
106114 // Establish relations
107115 const success = await Algorithms . establishRelations ( relations )
0 commit comments