Skip to content

Commit

Permalink
fix: Import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hampfh committed Oct 1, 2024
1 parent d31a6d4 commit f5aca5d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 32 deletions.
27 changes: 9 additions & 18 deletions apps/server/src/api/routes/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::api::models::user_model::User;
use crate::external_related::code_unwrapper::unwrap_code;
use crate::external_related::github::close_issue::{close_issue, CloseType};
use crate::external_related::github::create_issue_comment::create_issue_comment;
use crate::external_related::github::webhook_schema::{GithubPayload, Label};
use crate::external_related::github::webhook_schema::{GithubLabel, GithubPayload};
use crate::match_maker::match_executor::MatchReport;
use crate::match_maker::placements::run_placements;
use crate::match_maker::regenerate_markdown_files::regen_markdown_files_and_update_repo;
Expand Down Expand Up @@ -112,35 +112,26 @@ pub async fn submit_challenge(
}
}

fn valid_request(action: &String, labels: &Vec<Label>) -> bool {
fn valid_request(action: &String, labels: &Vec<GithubLabel>) -> bool {
return action == "opened" && labels.iter().any(|current| current.name == "challenger");
}

#[cfg(test)]
mod tests {
use super::*;
use actix_web::{test, App};

#[actix_web::test]
async fn test_valid_request() {
let action = "opened".to_string();
let labels = vec![Label {
let labels = vec![GithubLabel {
name: "challenger".to_string(),
node_id: todo!(),
url: todo!(),
color: todo!(),
default: todo!(),
description: todo!(),
node_id: String::new(),
url: String::new(),
color: String::new(),
default: false,
description: String::new(),
}];
assert_eq!(valid_request(&action, &labels), true);
assert_eq!(valid_request(&"closed".to_string(), &labels), false);
}

/* #[actix_web::test]
async fn test_invalid_request() {
let action = "closed".to_string();
let labels = vec![Label {
name: "challenger".to_string(),
}];
assert_eq!(valid_request(&action, &labels), false);
} */
}
2 changes: 1 addition & 1 deletion apps/server/src/api/routes/match_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) struct HttpResponseStruct {
}

#[get("/api/matches/{id}")]
pub(routes) async fn get_match_route(
pub(super) async fn get_match_route(
path: web::Path<String>,
) -> actix_web::Result<Json<HttpResponseStruct>> {
let conn = api::db::establish_connection().get().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/api/routes/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct HttpResponseStruct {
}

#[get("/api/matches")]
pub(routes) async fn get_matches_route() -> actix_web::Result<Json<HttpResponseStruct>> {
pub(super) async fn get_matches_route() -> actix_web::Result<Json<HttpResponseStruct>> {
let conn = api::db::establish_connection().get().unwrap();

let matches = Match::list_ids(&conn);
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/api/routes/ping.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use actix_web::get;

#[get("/api/ping")]
pub(routes) async fn get_api_ping() -> actix_web::Result<String> {
pub(super) async fn get_api_ping() -> actix_web::Result<String> {
return Ok("pong".to_string());
}

Expand Down
22 changes: 11 additions & 11 deletions apps/server/src/external_related/github/webhook_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct GithubPayload {
pub action: String,
pub issue: Issue,
pub repository: Repository,
pub sender: User,
pub issue: GithubIssue,
pub repository: GithubRepository,
pub sender: GithubUser,
}

#[derive(Serialize, Deserialize)]
pub struct Issue {
pub struct GithubIssue {
pub url: String,
pub repository_url: String,
pub labels_url: String,
Expand All @@ -20,8 +20,8 @@ pub struct Issue {
pub node_id: String,
pub number: i32,
pub title: String,
pub user: User,
pub labels: Vec<Label>,
pub user: GithubUser,
pub labels: Vec<GithubLabel>,
pub state: String,
pub locked: bool,
//pub assignee: null,
Expand All @@ -34,14 +34,14 @@ pub struct Issue {
pub author_association: String,
//pub active_lock_reason: null,
pub body: String, // This is where the code will come from
pub reactions: Reactions,
pub reactions: GithubReactions,
pub timeline_url: String,
//pub performed_via_github_app: null,
//pub state_reason: null
}

#[derive(Serialize, Deserialize)]
pub struct Reactions {
pub struct GithubReactions {
pub url: String,
pub total_count: i32,
//pub "+1": i32,
Expand All @@ -55,7 +55,7 @@ pub struct Reactions {
}

#[derive(Serialize, Deserialize)]
pub struct User {
pub struct GithubUser {
pub login: String, // Github username
pub id: i32,
pub node_id: String,
Expand All @@ -77,14 +77,14 @@ pub struct User {
}

#[derive(Serialize, Deserialize)]
pub struct Repository {
pub struct GithubRepository {
pub id: i32,
pub name: String,
pub full_name: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Label {
pub struct GithubLabel {
//pub id: String,
pub node_id: String,
pub url: String,
Expand Down

0 comments on commit f5aca5d

Please sign in to comment.