@@ -178,7 +178,7 @@ async fn start_main_server(config: ServerConfig, state: AppState) -> anyhow::Res
178178}
179179
180180struct IssueData {
181- source_id : String ,
181+ source_id : i64 ,
182182 action : Action ,
183183 title : String ,
184184 body : String ,
@@ -191,9 +191,9 @@ struct IssueData {
191191}
192192
193193struct CommentData {
194- source_id : String ,
194+ source_id : i64 ,
195195 action : Action ,
196- issue_id : String ,
196+ issue_id : i64 ,
197197 body : String ,
198198 url : String ,
199199}
@@ -402,7 +402,7 @@ async fn handle_webhooks(
402402 r#"insert into issues (source_id, source, title, body, is_pull_request, number, html_url, url, repository_full_name, embedding)
403403 values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"#
404404 )
405- . bind ( & issue. source_id )
405+ . bind ( issue. source_id )
406406 . bind ( issue. source . to_string ( ) )
407407 . bind ( issue. title )
408408 . bind ( issue. body )
@@ -612,7 +612,7 @@ async fn handle_webhooks(
612612 Vector :: from ( raw_embedding) ;
613613 let issue_id: Option < i32 > = match sqlx:: query_scalar!(
614614 "select id from issues where source_id = $1" ,
615- issue. id. to_string ( )
615+ issue. id
616616 )
617617 . fetch_optional ( & pool)
618618 . await {
@@ -630,7 +630,7 @@ async fn handle_webhooks(
630630 values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
631631 returning id"#
632632 )
633- . bind ( issue. id . to_string ( ) )
633+ . bind ( issue. id )
634634 . bind ( source)
635635 . bind ( issue. title )
636636 . bind ( issue. body )
@@ -751,7 +751,7 @@ async fn handle_webhooks(
751751 let embedding = Vector :: from ( raw_embedding) ;
752752 let issue_id: Option < i32 > = match sqlx:: query_scalar!(
753753 "select id from issues where source_id = $1" ,
754- issue. id. to_string ( )
754+ issue. id
755755 )
756756 . fetch_optional ( & pool)
757757 . await
@@ -774,7 +774,7 @@ async fn handle_webhooks(
774774 values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
775775 returning id"#
776776 )
777- . bind ( issue. id . to_string ( ) )
777+ . bind ( issue. id )
778778 . bind ( source)
779779 . bind ( issue. title )
780780 . bind ( issue. body )
@@ -868,7 +868,7 @@ async fn handle_webhooks(
868868 info ! ( "regenerating embeddings for {} issues" , total_issues) ;
869869 for ( current_issue_nb, issue) in issues. into_iter ( ) . enumerate ( ) {
870870 if let Err ( err) =
871- update_issue_embeddings ( & embedding_api, & pool, & issue. source_id )
871+ update_issue_embeddings ( & embedding_api, & pool, issue. source_id )
872872 . await
873873 {
874874 error ! (
@@ -927,7 +927,7 @@ async fn handle_webhooks(
927927 } ;
928928
929929 if let Some ( issue_id) = issue_id {
930- if let Err ( err) = update_issue_embeddings ( & embedding_api, & pool, & issue_id) . await {
930+ if let Err ( err) = update_issue_embeddings ( & embedding_api, & pool, issue_id) . await {
931931 error ! (
932932 issue_id = issue_id,
933933 err = err. to_string( ) ,
@@ -941,15 +941,15 @@ async fn handle_webhooks(
941941async fn update_issue_embeddings (
942942 embedding_api : & EmbeddingApi ,
943943 pool : & Pool < Postgres > ,
944- issue_id : & str ,
944+ issue_id : i64 ,
945945) -> anyhow:: Result < ( ) > {
946946 let issue = sqlx:: query!(
947947 r#"
948948 SELECT
949949 i.title,
950950 i.body,
951951 (
952- SELECT JSON_AGG(c.body)
952+ SELECT JSON_AGG(c.body ORDER BY c.source_id )
953953 FROM comments AS c
954954 WHERE c.issue_id = i.id
955955 ) AS comments
0 commit comments