@@ -14,7 +14,6 @@ use crate::{
1414} ;
1515use log:: { debug, info} ;
1616use postgres:: Client ;
17- use regex:: Regex ;
1817use serde_json:: Value ;
1918use slug:: slugify;
2019
@@ -53,14 +52,14 @@ pub(crate) fn add_package_into_database(
5352 dependencies, target_name, yanked, build_status,
5453 rustdoc_status, test_status, license, repository_url,
5554 homepage_url, description, description_long, readme,
56- authors, keywords, have_examples, downloads, files,
55+ keywords, have_examples, downloads, files,
5756 doc_targets, is_library, doc_rustc_version,
5857 documentation_url, default_target, features, github_repo
5958 )
6059 VALUES (
6160 $1, $2, $3, $4, $5, $6, $7, $8, $9,
6261 $10, $11, $12, $13, $14, $15, $16, $17, $18,
63- $19, $20, $21, $22, $23, $24, $25, $26, $27
62+ $19, $20, $21, $22, $23, $24, $25, $26
6463 )
6564 ON CONFLICT (crate_id, version) DO UPDATE
6665 SET release_time = $3,
@@ -76,18 +75,17 @@ pub(crate) fn add_package_into_database(
7675 description = $13,
7776 description_long = $14,
7877 readme = $15,
79- authors = $16,
80- keywords = $17,
81- have_examples = $18,
82- downloads = $19,
83- files = $20,
84- doc_targets = $21,
85- is_library = $22,
86- doc_rustc_version = $23,
87- documentation_url = $24,
88- default_target = $25,
89- features = $26,
90- github_repo = $27
78+ keywords = $16,
79+ have_examples = $17,
80+ downloads = $18,
81+ files = $19,
82+ doc_targets = $20,
83+ is_library = $21,
84+ doc_rustc_version = $22,
85+ documentation_url = $23,
86+ default_target = $24,
87+ features = $25,
88+ github_repo = $26
9189 RETURNING id" ,
9290 & [
9391 & crate_id,
@@ -105,7 +103,6 @@ pub(crate) fn add_package_into_database(
105103 & metadata_pkg. description ,
106104 & rustdoc,
107105 & readme,
108- & serde_json:: to_value ( & metadata_pkg. authors ) ?,
109106 & serde_json:: to_value ( & metadata_pkg. keywords ) ?,
110107 & has_examples,
111108 & registry_data. downloads ,
@@ -123,7 +120,6 @@ pub(crate) fn add_package_into_database(
123120 let release_id: i32 = rows[ 0 ] . get ( 0 ) ;
124121
125122 add_keywords_into_database ( conn, & metadata_pkg, release_id) ?;
126- add_authors_into_database ( conn, & metadata_pkg, release_id) ?;
127123 add_compression_into_database ( conn, compression_algorithms. into_iter ( ) , release_id) ?;
128124
129125 // Update the crates table with the new release
@@ -344,52 +340,6 @@ fn add_keywords_into_database(
344340 Ok ( ( ) )
345341}
346342
347- /// Adds authors into database
348- fn add_authors_into_database (
349- conn : & mut Client ,
350- pkg : & MetadataPackage ,
351- release_id : i32 ,
352- ) -> Result < ( ) > {
353- let author_capture_re = Regex :: new ( "^([^><]+)<*(.*?)>*$" ) . unwrap ( ) ;
354- for author in & pkg. authors {
355- if let Some ( author_captures) = author_capture_re. captures ( & author[ ..] ) {
356- let author = author_captures
357- . get ( 1 )
358- . map ( |m| m. as_str ( ) )
359- . unwrap_or ( "" )
360- . trim ( ) ;
361- let email = author_captures
362- . get ( 2 )
363- . map ( |m| m. as_str ( ) )
364- . unwrap_or ( "" )
365- . trim ( ) ;
366- let slug = slugify ( & author) ;
367-
368- let author_id: i32 = {
369- let rows = conn. query ( "SELECT id FROM authors WHERE slug = $1" , & [ & slug] ) ?;
370- if !rows. is_empty ( ) {
371- rows[ 0 ] . get ( 0 )
372- } else {
373- conn. query (
374- "INSERT INTO authors (name, email, slug) VALUES ($1, $2, $3)
375- RETURNING id" ,
376- & [ & author, & email, & slug] ,
377- ) ?[ 0 ]
378- . get ( 0 )
379- }
380- } ;
381-
382- // add relationship
383- let _ = conn. query (
384- "INSERT INTO author_rels (rid, aid) VALUES ($1, $2)" ,
385- & [ & release_id, & author_id] ,
386- ) ;
387- }
388- }
389-
390- Ok ( ( ) )
391- }
392-
393343pub fn update_crate_data_in_database (
394344 conn : & mut Client ,
395345 name : & str ,
0 commit comments