mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 05:55:42 +09:00
add interactive dispatch_checker
- TODO: add test!
This commit is contained in:
parent
8d75dcd0e9
commit
70903ec124
1 changed files with 62 additions and 0 deletions
|
@ -68,4 +68,66 @@ function is_dispatchable(conn::DbConnection, psbid::Int64)
|
|||
return missing
|
||||
end
|
||||
|
||||
function interactive_dispatch_checker(conn::DbConnection)
|
||||
dispatch_list = Int64[]
|
||||
|
||||
println("Type \"quit\" to exit")
|
||||
for _ in 1:1000
|
||||
printstyled("PSBoard ID: ", bold = true)
|
||||
psbid = let
|
||||
rawin = readline()
|
||||
if lowercase(rawin) == "quit"
|
||||
printstyled("Quit\n", italic = true)
|
||||
println()
|
||||
break
|
||||
end
|
||||
m = match(r"^PS(\d+)", rawin)
|
||||
if isnothing(m)
|
||||
printstyled("Invalid input\n", color = :red)
|
||||
continue
|
||||
end
|
||||
parse(Int64, m[1])
|
||||
end
|
||||
isdispatchable = is_dispatchable(conn, psbid)
|
||||
if ismissing(isdispatchable)
|
||||
printstyled("Please determine [y/n]: ", underline = true, color = :cyan)
|
||||
isdispatchable = let
|
||||
rawin = readline()
|
||||
@info "" rawin
|
||||
if rawin == "y" || rawin == "Y"
|
||||
true
|
||||
elseif rawin == "n" || rawin == "N"
|
||||
false
|
||||
else
|
||||
@warn "Invalid input falling back to \"no\""
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
if isdispatchable
|
||||
printstyled("Ok\n", bold = true, color = :green)
|
||||
if psbid in dispatch_list
|
||||
println("PSBoard ID $(psbid) is already in dispatch list")
|
||||
else
|
||||
push!(dispatch_list, psbid)
|
||||
println("Added to dispatch list")
|
||||
end
|
||||
else
|
||||
printstyled("No\n", bold = true, color = :red)
|
||||
end
|
||||
end
|
||||
|
||||
printstyled("Finished\n")
|
||||
join(dispatch_list, "\n") |> print
|
||||
println()
|
||||
printstyled("Paste the result", underline = true)
|
||||
|
||||
return dispatch_list
|
||||
end
|
||||
|
||||
function interactive_dispatch_checker(database_file::AbstractString)
|
||||
conn = DbConnection(SQLite.DB(database_file))
|
||||
interactive_dispatch_checker(conn)
|
||||
end
|
||||
|
||||
end # module DispatchChecker
|
||||
|
|
Loading…
Add table
Reference in a new issue