2026-05-06 01:42:38 +08:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
|
|
use crate::{api, query};
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct Repository {
|
|
|
|
|
pub id: u64,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub full_name: String,
|
|
|
|
|
pub private: bool,
|
|
|
|
|
pub html_url: String,
|
|
|
|
|
pub description: Option<String>,
|
|
|
|
|
pub default_branch: String,
|
|
|
|
|
pub owner: Owner,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct Owner {
|
|
|
|
|
pub login: String,
|
|
|
|
|
pub id: api::user::Id,
|
|
|
|
|
pub avatar_url: String,
|
|
|
|
|
pub html_url: String,
|
|
|
|
|
}
|
2026-04-20 15:13:26 +01:00
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct List;
|
|
|
|
|
|
2026-04-21 20:30:41 +01:00
|
|
|
impl query::QueryFn for List {
|
2026-05-06 01:42:38 +08:00
|
|
|
type Data = Vec<Repository>;
|
|
|
|
|
type Error = api::Error;
|
|
|
|
|
type Context = api::QueryContext;
|
2026-04-20 15:13:26 +01:00
|
|
|
|
2026-05-06 01:42:38 +08:00
|
|
|
fn key(&self) -> query::Key {
|
|
|
|
|
"repo/list".into()
|
2026-04-20 15:13:26 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-06 01:42:38 +08:00
|
|
|
async fn run(&self, c: &Self::Context) -> Result<Self::Data, Self::Error> {
|
|
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
|
if c.should_use_fixtures {
|
|
|
|
|
return super::mock::list_repos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let params = [("sort", "updated"), ("per_page", "100")];
|
|
|
|
|
let res = c
|
|
|
|
|
.github_request(reqwest::Method::GET, "/user/repos")?
|
|
|
|
|
.query(¶ms)
|
|
|
|
|
.send()
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
api::parse_response(res).await
|
2026-04-20 15:13:26 +01:00
|
|
|
}
|
|
|
|
|
}
|