Detailed changes
@@ -1,4 +1,3 @@
-pub mod contributors;
pub mod events;
pub mod extensions;
@@ -91,7 +90,6 @@ pub fn routes(rpc_server: Arc<rpc::Server>) -> Router<(), Body> {
Router::new()
.route("/users/:id/access_tokens", post(create_access_token))
.route("/rpc_server_snapshot", get(get_rpc_server_snapshot))
- .merge(contributors::router())
.layer(
ServiceBuilder::new()
.layer(Extension(rpc_server))
@@ -1,44 +0,0 @@
-use std::sync::Arc;
-
-use axum::{
- Extension, Json, Router,
- extract::{self},
- routing::get,
-};
-use serde::Deserialize;
-
-use crate::{AppState, Result};
-
-pub fn router() -> Router {
- Router::new().route("/contributors", get(get_contributors).post(add_contributor))
-}
-
-async fn get_contributors(Extension(app): Extension<Arc<AppState>>) -> Result<Json<Vec<String>>> {
- Ok(Json(app.db.get_contributors().await?))
-}
-
-#[derive(Debug, Deserialize)]
-struct AddContributorBody {
- github_user_id: i32,
- github_login: String,
- github_email: Option<String>,
- github_name: Option<String>,
- github_user_created_at: chrono::DateTime<chrono::Utc>,
-}
-
-async fn add_contributor(
- Extension(app): Extension<Arc<AppState>>,
- extract::Json(params): extract::Json<AddContributorBody>,
-) -> Result<()> {
- let initial_channel_id = app.config.auto_join_channel_id;
- app.db
- .add_contributor(
- ¶ms.github_login,
- params.github_user_id,
- params.github_email.as_deref(),
- params.github_name.as_deref(),
- params.github_user_created_at,
- initial_channel_id,
- )
- .await
-}
@@ -1,27 +1,8 @@
use super::*;
impl Database {
- /// Retrieves the GitHub logins of all users who have signed the CLA.
- pub async fn get_contributors(&self) -> Result<Vec<String>> {
- self.transaction(|tx| async move {
- #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
- enum QueryGithubLogin {
- GithubLogin,
- }
-
- Ok(contributor::Entity::find()
- .inner_join(user::Entity)
- .order_by_asc(contributor::Column::SignedAt)
- .select_only()
- .column(user::Column::GithubLogin)
- .into_values::<_, QueryGithubLogin>()
- .all(&*tx)
- .await?)
- })
- .await
- }
-
/// Records that a given user has signed the CLA.
+ #[cfg(test)]
pub async fn add_contributor(
&self,
github_login: &str,
@@ -29,8 +29,6 @@ pub enum Relation {
HostedProjects,
#[sea_orm(has_many = "super::channel_member::Entity")]
ChannelMemberships,
- #[sea_orm(has_one = "super::contributor::Entity")]
- Contributor,
}
impl Related<super::access_token::Entity> for Entity {
@@ -1,6 +1,5 @@
mod buffer_tests;
mod channel_tests;
-mod contributor_tests;
mod db_tests;
mod extension_tests;
mod migrations;
@@ -1,45 +0,0 @@
-use chrono::Utc;
-
-use super::Database;
-use crate::{db::NewUserParams, test_both_dbs};
-use std::sync::Arc;
-
-test_both_dbs!(
- test_contributors,
- test_contributors_postgres,
- test_contributors_sqlite
-);
-
-async fn test_contributors(db: &Arc<Database>) {
- db.create_user(
- "user1@example.com",
- None,
- false,
- NewUserParams {
- github_login: "user1".to_string(),
- github_user_id: 1,
- },
- )
- .await
- .unwrap();
-
- assert_eq!(db.get_contributors().await.unwrap(), Vec::<String>::new());
-
- let user1_created_at = Utc::now();
- db.add_contributor("user1", 1, None, None, user1_created_at, None)
- .await
- .unwrap();
- assert_eq!(
- db.get_contributors().await.unwrap(),
- vec!["user1".to_string()]
- );
-
- let user2_created_at = Utc::now();
- db.add_contributor("user2", 2, None, None, user2_created_at, None)
- .await
- .unwrap();
- assert_eq!(
- db.get_contributors().await.unwrap(),
- vec!["user1".to_string(), "user2".to_string()]
- );
-}