Skip to content

Commit 46b105e

Browse files
committed
fix: PR feedback
1 parent bc20584 commit 46b105e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/main.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
use actix_cors::Cors;
2-
use actix_web::{
3-
get, middleware::Logger, post, web, App, HttpResponse, HttpServer, Responder, Result,
4-
};
2+
use actix_web::middleware::Logger;
3+
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder, Result};
54
use actix_web_httpauth::middleware::HttpAuthentication;
65
use async_std::prelude::*;
76
use chrono::Utc;
87
use serde::{Deserialize, Serialize};
98
use serde_json::json;
10-
use std::{
11-
fs,
12-
io::Write,
13-
net::{IpAddr, Ipv4Addr, SocketAddr},
14-
process,
15-
process::{Command, Output},
16-
str, thread,
17-
};
9+
use std::io::Write;
10+
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
11+
use std::process::{Command, Output};
12+
use std::{fs, process, str, thread};
1813

1914
#[macro_use]
2015
extern crate log;
@@ -130,7 +125,7 @@ fn run_project(project: Project, mut log: std::fs::File, mut metadata_log: std::
130125
metadata_log.write_all(json_metadata.as_bytes()).unwrap();
131126
}
132127

133-
fn spawn_job(logs_dir: &String, project: Project) -> String {
128+
fn spawn_job(logs_dir: &str, project: Project) -> String {
134129
let job_name = create_job_name(&project.name);
135130
let file_name = create_log_name(&job_name, logs_dir);
136131
let metadata_file_name = create_metadata_log_name(&job_name, logs_dir);
@@ -170,7 +165,7 @@ async fn webhook(body: web::Json<WebhookPayload>, ctx: web::Data<Context>) -> im
170165
}
171166

172167
#[get("/jobs")]
173-
async fn get_jogs(ctx: web::Data<Context>) -> Result<web::Json<serde_json::value::Value>> {
168+
async fn get_jobs(ctx: web::Data<Context>) -> Result<web::Json<serde_json::value::Value>> {
174169
let log_dir = shellexpand::tilde(&ctx.logs_dir).into_owned();
175170
let mut logs: Vec<String> = Vec::new();
176171

@@ -181,8 +176,8 @@ async fn get_jogs(ctx: web::Data<Context>) -> Result<web::Json<serde_json::value
181176

182177
let name = path.file_name().unwrap().to_owned().into_string().unwrap();
183178

184-
if name.ends_with(".json") {
185-
logs.push(name.replace(".json", ""));
179+
if name.ends_with(".log") {
180+
logs.push(name.replace(".log", ""));
186181
}
187182
}
188183

@@ -316,7 +311,7 @@ async fn main() -> std::io::Result<()> {
316311
.wrap(HttpAuthentication::bearer(auth::validator))
317312
.wrap(Cors::new().supports_credentials().finish())
318313
.service(webhook)
319-
.service(get_jogs)
314+
.service(get_jobs)
320315
.service(get_job_by_name)
321316
})
322317
.bind(socket)?

0 commit comments

Comments
 (0)