From 64056a89d8506252ec60093da3849161c210ab41 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 11:29:36 +0900 Subject: [PATCH 1/5] add version to database --- src/import_data.jl | 12 ++++++++++++ src/sql/create_table.sql | 4 ++++ test/runtests.jl | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/import_data.jl b/src/import_data.jl index 596a17b..5aba398 100644 --- a/src/import_data.jl +++ b/src/import_data.jl @@ -1,3 +1,15 @@ +function insert_version_info(db::SQLite.DB) + stmt = DBInterface.prepare( + db, + sql""" + INSERT INTO versions VALUES (:converter) + """, + ) + DBInterface.execute(stmt, (; converter = pkgversion(@__MODULE__))) + + nothing +end + """ insert_qaqc_campaign_id(db::SQLite.DB) diff --git a/src/sql/create_table.sql b/src/sql/create_table.sql index 382cf02..0ea0da2 100644 --- a/src/sql/create_table.sql +++ b/src/sql/create_table.sql @@ -1,3 +1,7 @@ +CREATE TABLE versions ( + converter TEXT, +); + CREATE TABLE ps_boards ( id INTEGER NOT NULL PRIMARY KEY, daughterboard_id INTEGER diff --git a/test/runtests.jl b/test/runtests.jl index 72a8a70..559dfa7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -34,6 +34,8 @@ true || include("../src/PSBoardDataBase.jl") db = PSBoardDataBase.create_database(dbpath) @info "" db + @test PSBoardDataBase.insert_version_info(db) |> isnothing + @test PSBoardDataBase.insert_qaqc_campaign_id(db) |> isnothing @test PSBoardDataBase.insert_qaqc_positions(db) |> isnothing From 066e0d5e464de4c4a6e245814c1a5b89b12ce127 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 14:38:27 +0900 Subject: [PATCH 2/5] fix: type and sql for insert version --- src/import_data.jl | 7 ++++++- src/sql/create_table.sql | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/import_data.jl b/src/import_data.jl index 5aba398..408ed07 100644 --- a/src/import_data.jl +++ b/src/import_data.jl @@ -1,3 +1,8 @@ +""" + insert_version_info(db::SQLite.DB) + +Insert version information of this software as string. +""" function insert_version_info(db::SQLite.DB) stmt = DBInterface.prepare( db, @@ -5,7 +10,7 @@ function insert_version_info(db::SQLite.DB) INSERT INTO versions VALUES (:converter) """, ) - DBInterface.execute(stmt, (; converter = pkgversion(@__MODULE__))) + DBInterface.execute(stmt, (; converter = pkgversion(@__MODULE__) |> string)) nothing end diff --git a/src/sql/create_table.sql b/src/sql/create_table.sql index 0ea0da2..610dee0 100644 --- a/src/sql/create_table.sql +++ b/src/sql/create_table.sql @@ -1,5 +1,5 @@ CREATE TABLE versions ( - converter TEXT, + converter TEXT ); CREATE TABLE ps_boards ( From ead17f3d58d19e431477c5ec98458d0de05e15c8 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 14:39:43 +0900 Subject: [PATCH 3/5] add: skew column to positions --- src/PSBoardDataBase.jl | 5 ++++- src/import_data.jl | 20 +++++++++++++++++--- src/sql/create_table.sql | 3 ++- test/runtests.jl | 14 +++++++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/PSBoardDataBase.jl b/src/PSBoardDataBase.jl index 1ab9ea2..72c96f4 100644 --- a/src/PSBoardDataBase.jl +++ b/src/PSBoardDataBase.jl @@ -20,6 +20,7 @@ include("import_data.jl") runlist_csv::AbstractString, dispatch_csv::AbstractString, hundred_csv::AbstractString, + jathubs_csv::AbstractString, masterlog_dir::AbstractString, ) @@ -31,6 +32,7 @@ Create database at `dbpath` and import data from CSV and master log files. - `runlist_csv`: CSV of run lists exported from the Google sheets database - `dispatch_csv`: CSV of dispatch lists exported from the Google sheets database - `hundred_csv`: CSV of 100 tests results exported from the Google sheets database +- `jathubs_csv`: CSV for jathub list used in QAQC. Used to add skew. - `masterlog_dir`: path to the directory (`log`) where all JATHub master log is stored """ function create_database_from_exported_csvs( @@ -39,6 +41,7 @@ function create_database_from_exported_csvs( runlist_csv::AbstractString, dispatch_csv::AbstractString, hundred_csv::AbstractString, + jathubs_csv::AbstractString, masterlog_dir::AbstractString, ) db = create_database(dbpath) @@ -48,7 +51,7 @@ function create_database_from_exported_csvs( extra_100test_result_df = CSV.read(hundred_csv, DataFrame) insert_qaqc_campaign_id(db) - insert_qaqc_positions(db) + insert_qaqc_positions(db, jathubs_csv) add_psboard_ids(db, single_result_df) add_qaqc_runlist_from_runlist(db, runlist_table) diff --git a/src/import_data.jl b/src/import_data.jl index 408ed07..349c21c 100644 --- a/src/import_data.jl +++ b/src/import_data.jl @@ -45,11 +45,18 @@ function insert_qaqc_campaign_id(db::SQLite.DB) end """ - insert_qaqc_positions(db::SQLite.DB) + insert_qaqc_positions(db::SQLite.DB, jathub_db_table::DataFrame) Fill qaqc_positions table in `db`. +Argument `jathub_db_table` is for skew for each positions. """ -function insert_qaqc_positions(db::SQLite.DB) +function insert_qaqc_positions(db::SQLite.DB, jathub_db_table::DataFrame) + dropmissing!(jathub_db_table, :psb_position) + transform!( + jathub_db_table, + Symbol("立ち上がり [ns]") => ByRow(Float64) => Symbol("立ち上がり [ns]"), + ) + stmt = DBInterface.prepare( db, sql""" @@ -58,7 +65,8 @@ function insert_qaqc_positions(db::SQLite.DB) :id, :name, :station, - :position + :position, + :rising_ns ) """, ) @@ -69,6 +77,12 @@ function insert_qaqc_positions(db::SQLite.DB) name = ["B-$i-$j" for i in 0:1 for j in 1:9], station = [fill(0, 9); fill(1, 9)], position = [collect(1:9); collect(1:9)], + rising_ns = [ + filter( + :psb_position => (s -> !ismissing(s) && s == "B-$i-$j"), + jathub_db_table, + ).var"立ち上がり [ns]" |> first for i in 0:1 for j in 1:9 + ], ), ) diff --git a/src/sql/create_table.sql b/src/sql/create_table.sql index 610dee0..c820a55 100644 --- a/src/sql/create_table.sql +++ b/src/sql/create_table.sql @@ -93,7 +93,8 @@ CREATE TABLE qaqc_positions ( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL UNIQUE, station INTEGER NOT NULL, - position INTEGER NOT NULL + position INTEGER NOT NULL, + rising_ns NUMERIC NOT NULL ); CREATE VIEW qaqc_single_run_table diff --git a/test/runtests.jl b/test/runtests.jl index 559dfa7..e4f063c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,7 @@ using Test using PSBoardDataBase using CSV, DataFrames +using SQLite, DBInterface using Dates true || include("../src/PSBoardDataBase.jl") @@ -35,9 +36,20 @@ true || include("../src/PSBoardDataBase.jl") @info "" db @test PSBoardDataBase.insert_version_info(db) |> isnothing + let stmt + stmt = DBInterface.prepare( + db, + sql""" + SELECT * FROM versions + """, + ) + result = DBInterface.execute(stmt) |> DataFrame + @test nrow(result) |> ==(1) + end @test PSBoardDataBase.insert_qaqc_campaign_id(db) |> isnothing - @test PSBoardDataBase.insert_qaqc_positions(db) |> isnothing + jathub_list_df = CSV.read("input/PS board QAQC Data Base - JATHub db.csv", DataFrame) + @test PSBoardDataBase.insert_qaqc_positions(db, jathub_list_df) |> isnothing single_result_df = CSV.read("input/PS board QAQC Data Base - 本番1回試験・追加検証試験.csv", DataFrame) From de144d83c0852aa27dd92ca36b2ad84ef06a71c0 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 14:45:41 +0900 Subject: [PATCH 4/5] fix: add JATHub db CSV as a test dependency --- .../PS board QAQC Data Base - JATHub db.csv | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/input/PS board QAQC Data Base - JATHub db.csv diff --git a/test/input/PS board QAQC Data Base - JATHub db.csv b/test/input/PS board QAQC Data Base - JATHub db.csv new file mode 100644 index 0000000..0e79f8c --- /dev/null +++ b/test/input/PS board QAQC Data Base - JATHub db.csv @@ -0,0 +1,21 @@ +station,slot,jathub_sn,psb_position,,試験 run number,立ち上がり [ns],skew [ns] +0,0,121,,,,, +0,1,171,B-0-1,with UART,135,12.32142857,0.000 +0,2,123,B-0-2,,137,12.55357143,0.232 +0,3,124,B-0-3,,139,12.32142857,0.000 +0,4,66,B-0-4,,141,13.17857143,0.857 +0,5,126,B-0-5,,143,13.30357143,0.982 +0,6,127,B-0-6,,145,13.91071429,1.589 +0,7,128,B-0-7,,147,13.57142857,1.250 +0,8,129,B-0-8,,149,12.26785714,-0.054 +0,9,67,B-0-9,,151,14.03571429,1.714 +1,0,131,,,,, +1,1,166,B-1-1,with SiTCP,136,11.85714286,-0.464 +1,2,133,B-1-2,,138,12.01785714,-0.304 +1,3,134,B-1-3,,140,12.67857143,0.357 +1,4,135,B-1-4,,142,13.66071429,1.339 +1,5,132,B-1-5,,144,13.48214286,1.161 +1,6,137,B-1-6,,146,11.92857143,-0.393 +1,7,138,B-1-7,,148,12.07142857,-0.250 +1,8,139,B-1-8,,150,12.46428571,0.143 +1,9,140,B-1-9,,152,12.30357143,-0.018 \ No newline at end of file From 55e16329305c2197b39212fd2030e9ebe1cb98ba Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Mon, 30 Sep 2024 14:57:05 +0900 Subject: [PATCH 5/5] update: CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a4ccb..527fc39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `versions` table to store versoin information of converter(this software) +- Add `skew` columnt to `qaqc_positions` table + ## [0.1.0] ### Added