From cf55b5601cd9bddce082de432996dbd57823df3a Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 11:06:53 +0900 Subject: [PATCH] (WIP) tried to use Strapping, but it had a bag (gave up) --- Project.toml | 2 ++ src/PSBoardDataBase.jl | 3 ++- src/queries.jl | 9 +++++++++ test/runtests.jl | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/queries.jl diff --git a/Project.toml b/Project.toml index 757362c..c17b9bc 100644 --- a/Project.toml +++ b/Project.toml @@ -10,6 +10,8 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9" +Strapping = "3787371a-436b-4cb0-be6b-e772a55e3ebe" +StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [weakdeps] diff --git a/src/PSBoardDataBase.jl b/src/PSBoardDataBase.jl index 1ab9ea2..cf01d55 100644 --- a/src/PSBoardDataBase.jl +++ b/src/PSBoardDataBase.jl @@ -7,6 +7,7 @@ using CSV using DataFrames using Dates +include("types.jl") include("parse_qaqc_master_log.jl") include("create_table.jl") @@ -60,6 +61,6 @@ function create_database_from_exported_csvs( db end -greet() = print("Hello World!") +include("queries.jl") end # module PSBoardDataBase diff --git a/src/queries.jl b/src/queries.jl new file mode 100644 index 0000000..80bcc6b --- /dev/null +++ b/src/queries.jl @@ -0,0 +1,9 @@ +function get_board_qaqc_summary(db::SQLite.DB, psboard_id::Int64) + stmt = DBInterface.prepare( + db, + sql"SELECT * FROM qaqc_single_run_table WHERE psboard_id = (?)", + ) + df = DBInterface.execute(stmt, (psboard_id,)) |> DataFrame + + df +end diff --git a/test/runtests.jl b/test/runtests.jl index 72a8a70..37e0c6a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,29 @@ using Dates true || include("../src/PSBoardDataBase.jl") @testset "PSBoardDataBase" begin + @testset "types" begin + @testset "StructTypes and Strapping" begin + using Strapping + + @info "" Strapping.construct( + Vector{PSBoardDataBase.PsBoard}, + (id = [123, 10], daughterboard_id = [nothing, 12345]), + ) + @test Strapping.construct( + PSBoardDataBase.PsBoard, + (id = [123], daughterboard_id = [nothing]), + ) == PSBoardDataBase.PsBoard(123, nothing) + + @test Strapping.construct( + Vector{PSBoardDataBase.PsBoard}, + [(100, nothing), (200, 12345)], + ) == PSBoardDataBase.PsBoard[ + PSBoardDataBase.PsBoard(100, nothing), + PSBoardDataBase.PsBoard(200, 12345), + ] + end + end + @testset "parse master log" begin masterlog_metadata::PSBoardDataBase.QaqcMasterLog.QaqcMasterLogMetadata = PSBoardDataBase.QaqcMasterLog.parse_master_log("input/log/57_long.log")