MCPcopy Create free account
hub / github.com/emwalker/digraph / call

Method call

backend/src/psql/user.rs:100–132  ·  view source on GitHub ↗
(&self, pool: &PgPool)

Source from the content-addressed store, hash-verified

98 }
99
100 pub async fn call(&self, pool: &PgPool) -> Result<UpsertUserResult> {
101 let username = &self.input.github_username;
102
103 let query = format!(
104 r#"select
105 {USER_FIELDS}
106 from users u
107 left join users_repositories ur on u.id = ur.user_id
108 join github_accounts ga on u.id = ga.user_id
109 where ga.username = $1
110 group by u.id"#
111 );
112 let result = sqlx::query_as::<_, Row>(&query)
113 .bind(username)
114 .fetch_optional(pool)
115 .await?;
116
117 let user = match result {
118 Some(row) => row,
119 None => {
120 log::info!("user {} not found, creating", username);
121 let mut tx = pool.begin().await?;
122 let user = self.create_github_user(&mut tx).await?;
123 CompleteRegistration::new(&user, &self.input.github_username)
124 .call(&mut tx)
125 .await?;
126 tx.commit().await?;
127 user
128 }
129 };
130
131 Ok(UpsertUserResult { user })
132 }
133
134 async fn create_github_user(&self, tx: &mut PgTransaction<'_>) -> Result<Row> {
135 let row = sqlx::query_as::<_, Row>(

Callers

nothing calls this directly

Calls 4

fetch_userFunction · 0.85
create_github_userMethod · 0.80
commitMethod · 0.80
try_intoMethod · 0.45

Tested by

no test coverage detected