mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 05:55:42 +09:00
add: skew column to positions
This commit is contained in:
parent
066e0d5e46
commit
ead17f3d58
4 changed files with 36 additions and 6 deletions
|
@ -20,6 +20,7 @@ include("import_data.jl")
|
||||||
runlist_csv::AbstractString,
|
runlist_csv::AbstractString,
|
||||||
dispatch_csv::AbstractString,
|
dispatch_csv::AbstractString,
|
||||||
hundred_csv::AbstractString,
|
hundred_csv::AbstractString,
|
||||||
|
jathubs_csv::AbstractString,
|
||||||
masterlog_dir::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
|
- `runlist_csv`: CSV of run lists exported from the Google sheets database
|
||||||
- `dispatch_csv`: CSV of dispatch 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
|
- `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
|
- `masterlog_dir`: path to the directory (`log`) where all JATHub master log is stored
|
||||||
"""
|
"""
|
||||||
function create_database_from_exported_csvs(
|
function create_database_from_exported_csvs(
|
||||||
|
@ -39,6 +41,7 @@ function create_database_from_exported_csvs(
|
||||||
runlist_csv::AbstractString,
|
runlist_csv::AbstractString,
|
||||||
dispatch_csv::AbstractString,
|
dispatch_csv::AbstractString,
|
||||||
hundred_csv::AbstractString,
|
hundred_csv::AbstractString,
|
||||||
|
jathubs_csv::AbstractString,
|
||||||
masterlog_dir::AbstractString,
|
masterlog_dir::AbstractString,
|
||||||
)
|
)
|
||||||
db = create_database(dbpath)
|
db = create_database(dbpath)
|
||||||
|
@ -48,7 +51,7 @@ function create_database_from_exported_csvs(
|
||||||
extra_100test_result_df = CSV.read(hundred_csv, DataFrame)
|
extra_100test_result_df = CSV.read(hundred_csv, DataFrame)
|
||||||
|
|
||||||
insert_qaqc_campaign_id(db)
|
insert_qaqc_campaign_id(db)
|
||||||
insert_qaqc_positions(db)
|
insert_qaqc_positions(db, jathubs_csv)
|
||||||
|
|
||||||
add_psboard_ids(db, single_result_df)
|
add_psboard_ids(db, single_result_df)
|
||||||
add_qaqc_runlist_from_runlist(db, runlist_table)
|
add_qaqc_runlist_from_runlist(db, runlist_table)
|
||||||
|
|
|
@ -45,11 +45,18 @@ function insert_qaqc_campaign_id(db::SQLite.DB)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
insert_qaqc_positions(db::SQLite.DB)
|
insert_qaqc_positions(db::SQLite.DB, jathub_db_table::DataFrame)
|
||||||
|
|
||||||
Fill qaqc_positions table in `db`.
|
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(
|
stmt = DBInterface.prepare(
|
||||||
db,
|
db,
|
||||||
sql"""
|
sql"""
|
||||||
|
@ -58,7 +65,8 @@ function insert_qaqc_positions(db::SQLite.DB)
|
||||||
:id,
|
:id,
|
||||||
:name,
|
:name,
|
||||||
:station,
|
: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],
|
name = ["B-$i-$j" for i in 0:1 for j in 1:9],
|
||||||
station = [fill(0, 9); fill(1, 9)],
|
station = [fill(0, 9); fill(1, 9)],
|
||||||
position = [collect(1:9); collect(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
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,8 @@ CREATE TABLE qaqc_positions (
|
||||||
id INTEGER NOT NULL PRIMARY KEY,
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
name TEXT NOT NULL UNIQUE,
|
name TEXT NOT NULL UNIQUE,
|
||||||
station INTEGER NOT NULL,
|
station INTEGER NOT NULL,
|
||||||
position INTEGER NOT NULL
|
position INTEGER NOT NULL,
|
||||||
|
rising_ns NUMERIC NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE VIEW qaqc_single_run_table
|
CREATE VIEW qaqc_single_run_table
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Test
|
using Test
|
||||||
using PSBoardDataBase
|
using PSBoardDataBase
|
||||||
using CSV, DataFrames
|
using CSV, DataFrames
|
||||||
|
using SQLite, DBInterface
|
||||||
using Dates
|
using Dates
|
||||||
|
|
||||||
true || include("../src/PSBoardDataBase.jl")
|
true || include("../src/PSBoardDataBase.jl")
|
||||||
|
@ -35,9 +36,20 @@ true || include("../src/PSBoardDataBase.jl")
|
||||||
@info "" db
|
@info "" db
|
||||||
|
|
||||||
@test PSBoardDataBase.insert_version_info(db) |> isnothing
|
@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_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 =
|
single_result_df =
|
||||||
CSV.read("input/PS board QAQC Data Base - 本番1回試験・追加検証試験.csv", DataFrame)
|
CSV.read("input/PS board QAQC Data Base - 本番1回試験・追加検証試験.csv", DataFrame)
|
||||||
|
|
Loading…
Add table
Reference in a new issue