add: skew column to positions

This commit is contained in:
Wataru Otsubo 2024-09-30 14:39:43 +09:00
parent 066e0d5e46
commit ead17f3d58
4 changed files with 36 additions and 6 deletions

View file

@ -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)

View file

@ -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
],
),
)

View file

@ -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

View file

@ -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)