2022-05-19 08:20:11 +02:00
|
|
|
module models
|
|
|
|
|
|
|
|
import time
|
2022-12-19 11:58:35 +01:00
|
|
|
import os
|
2022-05-19 08:20:11 +02:00
|
|
|
|
|
|
|
pub struct BuildLog {
|
2022-05-28 22:22:55 +02:00
|
|
|
pub mut:
|
2022-05-19 08:20:11 +02:00
|
|
|
id int [primary; sql: serial]
|
2022-06-14 22:25:40 +02:00
|
|
|
target_id int [nonull]
|
2022-05-19 08:20:11 +02:00
|
|
|
start_time time.Time [nonull]
|
|
|
|
end_time time.Time [nonull]
|
|
|
|
arch string [nonull]
|
|
|
|
exit_code int [nonull]
|
|
|
|
}
|
|
|
|
|
|
|
|
// str returns a string representation.
|
|
|
|
pub fn (bl &BuildLog) str() string {
|
|
|
|
mut parts := [
|
|
|
|
'id: $bl.id',
|
2022-06-14 22:25:40 +02:00
|
|
|
'target id: $bl.target_id',
|
2022-05-31 12:41:50 +02:00
|
|
|
'start time: $bl.start_time.local()',
|
|
|
|
'end time: $bl.end_time.local()',
|
|
|
|
'duration: ${bl.end_time - bl.start_time}',
|
2022-05-19 08:20:11 +02:00
|
|
|
'arch: $bl.arch',
|
|
|
|
'exit code: $bl.exit_code',
|
|
|
|
]
|
|
|
|
str := parts.join('\n')
|
|
|
|
|
|
|
|
return str
|
|
|
|
}
|
2022-05-19 22:43:38 +02:00
|
|
|
|
2022-12-19 11:58:35 +01:00
|
|
|
// path returns the path to the log file, relative to the logs directory
|
|
|
|
pub fn (bl &BuildLog) path() string {
|
|
|
|
filename := bl.start_time.custom_format('YYYY-MM-DD_HH-mm-ss')
|
|
|
|
|
|
|
|
return os.join_path(bl.target_id.str(), bl.arch, filename)
|
|
|
|
}
|
|
|
|
|
2022-05-19 22:43:38 +02:00
|
|
|
[params]
|
|
|
|
pub struct BuildLogFilter {
|
|
|
|
pub mut:
|
2022-05-29 21:07:46 +02:00
|
|
|
limit u64 = 25
|
|
|
|
offset u64
|
2022-06-14 22:25:40 +02:00
|
|
|
target int
|
2022-05-29 21:07:46 +02:00
|
|
|
before time.Time
|
|
|
|
after time.Time
|
|
|
|
arch string
|
2022-05-29 20:08:21 +02:00
|
|
|
exit_codes []string
|
2022-05-19 22:43:38 +02:00
|
|
|
}
|