mirror of
https://codeberg.org/Mo8it/git-webhook-client
synced 2024-11-26 11:41:34 +00:00
Add datetime to log
This commit is contained in:
parent
5b057d7cfa
commit
1805ac94d4
6 changed files with 18 additions and 7 deletions
|
@ -8,6 +8,7 @@ license-file = "LICENSE"
|
|||
|
||||
[dependencies]
|
||||
cached = "0.39.0"
|
||||
chrono = "0.4.22"
|
||||
diesel = { version = "2.0.2", features = [
|
||||
"r2d2",
|
||||
"sqlite",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE TABLE hooklog (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
datetime TEXT NOT NULL,
|
||||
repo_url TEXT NOT NULL,
|
||||
command_with_args TEXT NOT NULL,
|
||||
current_dir TEXT NOT NULL,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use chrono::Local;
|
||||
use diesel::prelude::*;
|
||||
use diesel::r2d2::{ConnectionManager, Pool};
|
||||
use std::env;
|
||||
|
@ -25,6 +26,7 @@ pub fn add_hook_log(pool: &DBPool, hook: &Hook, output: &Output) -> i32 {
|
|||
let command_with_args = hook.command.to_owned() + " " + &hook.args.join(" ");
|
||||
|
||||
let new_hook_log = NewHookLog {
|
||||
datetime: &Local::now().format("%d.%m.%Y %T").to_string(),
|
||||
repo_url: &hook.repo_url,
|
||||
command_with_args: &command_with_args,
|
||||
current_dir: &hook.current_dir,
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::schema::hooklog;
|
|||
#[derive(Queryable)]
|
||||
pub struct HookLog {
|
||||
pub id: i32,
|
||||
pub datetime: String,
|
||||
pub repo_url: String,
|
||||
pub command_with_args: String,
|
||||
pub current_dir: String,
|
||||
|
@ -16,6 +17,7 @@ pub struct HookLog {
|
|||
#[derive(Insertable)]
|
||||
#[diesel(table_name = hooklog)]
|
||||
pub struct NewHookLog<'a> {
|
||||
pub datetime: &'a str,
|
||||
pub repo_url: &'a str,
|
||||
pub command_with_args: &'a str,
|
||||
pub current_dir: &'a str,
|
||||
|
|
|
@ -12,6 +12,9 @@ pub fn index(db_state: &State<states::DB>, id: i32) -> String {
|
|||
"Hook log id:
|
||||
{}
|
||||
|
||||
Datetime:
|
||||
{}
|
||||
|
||||
Repository url:
|
||||
{}
|
||||
|
||||
|
@ -31,6 +34,7 @@ Status code:
|
|||
{}
|
||||
",
|
||||
hook_log.id,
|
||||
hook_log.datetime,
|
||||
hook_log.repo_url,
|
||||
hook_log.command_with_args,
|
||||
hook_log.current_dir,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
diesel::table! {
|
||||
hooklog (id) {
|
||||
id -> Integer,
|
||||
datetime -> Text,
|
||||
repo_url -> Text,
|
||||
command_with_args -> Text,
|
||||
current_dir -> Text,
|
||||
|
|
Loading…
Reference in a new issue