From 424a024dd4f78c13002f5c557ccfc5718e2f69a7 Mon Sep 17 00:00:00 2001 From: Dieter Menne Date: Mon, 13 Jan 2025 07:54:19 +0100 Subject: [PATCH] Version 1.4.0 Added scripts to git --- .Renviron | 4 +- .gitignore | 1 - DESCRIPTION | 4 +- R/app_server.R | 8 +-- inst/config.yml | 2 +- scripts/backup_volumes.sh | 70 ++++++++++++++++++++++++++ scripts/clean_ano_logs.sql | 17 +++++++ scripts/coverage.R | 8 +++ scripts/docker_get_data_volume_info.sh | 36 +++++++++++++ scripts/insert_x_consensus.sql | 9 ++++ scripts/remove_test_records.sql | 4 ++ scripts/workspace.code-workspace | 24 +++++++++ 12 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 scripts/backup_volumes.sh create mode 100644 scripts/clean_ano_logs.sql create mode 100644 scripts/coverage.R create mode 100644 scripts/docker_get_data_volume_info.sh create mode 100644 scripts/insert_x_consensus.sql create mode 100644 scripts/remove_test_records.sql create mode 100644 scripts/workspace.code-workspace diff --git a/.Renviron b/.Renviron index 972480c..8ed92e4 100644 --- a/.Renviron +++ b/.Renviron @@ -10,8 +10,8 @@ #R_CONFIG_ACTIVE=keycloak_test #R_CONFIG_ACTIVE=keycloak_devel #R_CONFIG_ACTIVE=sa_admin -#R_CONFIG_ACTIVE=sa_trainee -R_CONFIG_ACTIVE=sa_expert +R_CONFIG_ACTIVE=sa_trainee +#R_CONFIG_ACTIVE=sa_expert #R_CONFIG_ACTIVE=test #R_CONFIG_ACTIVE=sa_random_trainee #R_CONFIG_ACTIVE=sa_consensus diff --git a/.gitignore b/.gitignore index d9161c6..ce4a6b1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ letsencrypt log dev testthat*.rds -scripts/ covr/ *.gcno *.gcda diff --git a/DESCRIPTION b/DESCRIPTION index e4ee876..c9b6cc3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: anomanor Title: Anorectal Manometry Inter-Rater Agreement -Version: 1.3.6 -Date/Publication: 2024-10-11 +Version: 1.4.0 +Date/Publication: 12.01.2025 Author: Dieter Menne Authors@R: c( person("Dieter", "Menne", email="dieter.menne@menne-biomed.de", diff --git a/R/app_server.R b/R/app_server.R index ba028f0..8010da0 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -539,10 +539,11 @@ app_server = function(input, output, session) { # ----------- when to update network edges --------------------------- update_network = reactive({ - req(!is.null(rvalues$expert_classification)) + req(classification_phase()) + req(rvalues$expert_classification) req( (app_groups == "experts" && g$config$show_results_to_experts) || - app_user == 'x_consensus' ) - req(rvalues$finalized || app_user == 'x_consensus' ) + app_user == 'x_consensus' || + (app_groups == "trainees" && rvalues$finalized )) list( classification_phase(), record(), @@ -554,6 +555,7 @@ app_server = function(input, output, session) { # ----------- update network edges --------------------------- observeEvent(update_network(), { # edges is internal package global data + browser() cp = classification_phase() cm = classification_method() req(cp, cm) diff --git a/inst/config.yml b/inst/config.yml index 1373987..b4c9341 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -18,7 +18,7 @@ default: sa_trainee: app_user: caesar - app_groups: trainee + app_groups: trainees sa_admin: app_user: anton diff --git a/scripts/backup_volumes.sh b/scripts/backup_volumes.sh new file mode 100644 index 0000000..7ad9e21 --- /dev/null +++ b/scripts/backup_volumes.sh @@ -0,0 +1,70 @@ +#!/bin/bash +######################################################################### +#Name: backup-docker-volumes.sh +#Subscription: This Script backups docker volumes to a backup directory +##by A. Laub +#andreas[-at-]laub-home.de +# +#License: +#This program is free software: you can redistribute it and/or modify it +#under the terms of the GNU General Public License as published by the +#Free Software Foundation, either version 3 of the License, or (at your option) +#any later version. +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +#or FITNESS FOR A PARTICULAR PURPOSE. +# https://www.laub-home.de/wiki/Docker_Backup_und_Restore_-_eine_kleine_Anleitung +######################################################################### +#Set the language +export LANG="en_US.UTF-8" +#Load the Pathes +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +# set the variables + +# Where to store the Backup files? +BACKUPDIR=/backup/volumes + +# How many Days should a backup be available? +DAYS=10 + +# Timestamp definition for the backupfiles (example: $(date +"%Y%m%d%H%M") = 20200124-2034) +TIMESTAMP=$(date +"%Y%m%d%H%M") + +# Which Volumes you want to backup? +# Volumenames separated by space +VOLUME="anomanor_shiny_anomanor_keycloak anomanor_data" +# you can use "$(docker volume ls -q)" for all volumes +#VOLUME=$(docker volume ls -q) +# you can filter all Volumes with grep (include only) or grep -v (exclude) or a combination +# to do a filter for 2 or more arguments separate them with "\|" +# example: $(docker volume ls -q |grep 'project1\|project2' | grep -v 'database') +# to use volumes with name project1 and project2 but not database +#VOLUME=$(docker volume ls -q |grep 'project1\|project2' | grep -v 'database') +#VOLUME=$(docker volume ls -q | grep -v 'mailcowdockerized\|_db') + +# if you want to use memory limitation. Must be supported by the kernel. +#MEMORYLIMIT="-m 35m" + +### Do the stuff +echo -e "Start $TIMESTAMP Backup for Volumes:\n" +if [ ! -d $BACKUPDIR ]; then + mkdir -p $BACKUPDIR +fi + +for i in $VOLUME; do + echo -e " Backup von Volume:\n * $i"; + docker run --rm \ + -v $BACKUPDIR:/backup \ + -v $i:/data:ro \ + -e TIMESTAMP=$TIMESTAMP \ + -e i=$i ${MEMORYLIMIT} \ + --name volumebackup \ + alpine sh -c "cd /data && /bin/tar -czf /backup/$i-$TIMESTAMP.tar.gz ." + #debian:stretch-slim bash -c "cd /data && /bin/tar -czf /backup/$i-$TIMESTAMP.tar.gz ." + # dont delete last old backups! + OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.tar.gz |wc -l) + if [ $OLD_BACKUPS -gt $DAYS ]; then + find $BACKUPDIR -name "$i*.tar.gz" -daystart -mtime +$DAYS -delete + fi +done +echo -e "\n$TIMESTAMP Backup for Volumes completed\n" diff --git a/scripts/clean_ano_logs.sql b/scripts/clean_ano_logs.sql new file mode 100644 index 0000000..b85f907 --- /dev/null +++ b/scripts/clean_ano_logs.sql @@ -0,0 +1,17 @@ +-- delete from ano_logs where message like 'Session%'; +delete from ano_logs where message like 'Rendered%'; +delete from ano_logs where message like '%re-authenticate%'; +-- delete from ano_logs where message like 'Initial%'; +-- delete from ano_logs where message like 'Inserted%'; +delete from ano_logs where message like '%user test%'; +delete from ano_logs where message like 'Both%'; +delete from ano_logs where message like '0%'; +delete from ano_logs where message like 'Session start user anomanor%'; +delete from ano_logs where message like 'Session ended user anomanor%'; +delete from ano_logs where message like 'Executed%'; +delete from ano_logs where message like '%anton%'; +delete from ano_logs where message like 'Initially copied%'; +delete from ano_logs where message like '%since last history%'; +delete from ano_logs where message like 'Startup%'; +delete from ano_logs where message like '%history%'; +delete from ano_logs where message like 'Updated hi%'; diff --git a/scripts/coverage.R b/scripts/coverage.R new file mode 100644 index 0000000..542622c --- /dev/null +++ b/scripts/coverage.R @@ -0,0 +1,8 @@ +# https://github.com/r-lib/covr/issues/448#issuecomment-797738022 +options(covr.gcov = "C:/rtools40/mingw64/bin/gcov.exe") +cov = covr::package_coverage(line_exclusions = c( + "R/run_app.R", + "R/app_config.R" +# "R/keycloak.R" +) ) +covr::report(cov, file = "./covr/coverage-report.html") diff --git a/scripts/docker_get_data_volume_info.sh b/scripts/docker_get_data_volume_info.sh new file mode 100644 index 0000000..64a497e --- /dev/null +++ b/scripts/docker_get_data_volume_info.sh @@ -0,0 +1,36 @@ +#!/bin/bash + + +echo "List of all volumes:" +echo + +#Loop over all the data volumes +for docker_volume_id in $(docker volume ls -q) +do + echo "(Un)named volume: ${docker_volume_id}" + + #Obtain the size of the data volume by starting a docker container + #that uses this data volume and determines the size of this data volume + docker_volume_size=$(docker run --rm -t -v ${docker_volume_id}:/volume_data alpine sh -c "du -hs /volume_data | cut -f1" ) + + echo " Size: ${docker_volume_size}" + + #Determine the number of stopped and running containers that + #have a connection to this data volume + num_related_containers=$(docker ps -a --filter=volume=${docker_volume_id} -q | wc -l) + + #If the number is non-zero, we show the information about the container and the image + #and otherwise we show the message that are no connected containers + if (( $num_related_containers > 0 )) + then + echo " Connected containers:" + docker ps -a --filter=volume=${docker_volume_id} --format "{{.Names}} [{{.Image}}] ({{.Status}})" | while read containerDetails + do + echo " ${containerDetails}" + done + else + echo " No connected containers" + fi + + echo +done diff --git a/scripts/insert_x_consensus.sql b/scripts/insert_x_consensus.sql new file mode 100644 index 0000000..3041959 --- /dev/null +++ b/scripts/insert_x_consensus.sql @@ -0,0 +1,9 @@ +DELETE FROM classification where user = 'x_consensus'; + +INSERT INTO classification +(user, record, method, finalized, protocol_phase, classification_phase, classification, comment) + SELECT 'x_consensus' as user, record, method, 0 as finalized, 'consensus' as protocol_phase, classification_phase, classification, max(n) + FROM expert_classification + GROUP BY classification_phase, record, method + ORDER BY record, method, classification_phase; + diff --git a/scripts/remove_test_records.sql b/scripts/remove_test_records.sql new file mode 100644 index 0000000..c9cc605 --- /dev/null +++ b/scripts/remove_test_records.sql @@ -0,0 +1,4 @@ +PRAGMA foreign_keys = 1; +DELETE FROM classification WHERE record in + ('500613_ib', '000278_ib', '402865_ib', '404485_ib', '412011_ib'); +DELETE FROM user where [group] = 'admins'; diff --git a/scripts/workspace.code-workspace b/scripts/workspace.code-workspace new file mode 100644 index 0000000..6ef7874 --- /dev/null +++ b/scripts/workspace.code-workspace @@ -0,0 +1,24 @@ +{ + "folders": [ + { + "path": "..\\..\\..\\..\\..\\..\\tmp" + } + ], + "settings": { + "sqltools.connections": [ + { + "previewLimit": 50, + "driver": "SQLite", + "name": "naperge", + "database": "${workspaceFolder:naperg}/server/prisma/dev.db" + } + ], + "git.ignoreLimitWarning": true, + "python.pythonPath": "python" + }, + "extensions": { + "recommendations": [ + "platformio.platformio-ide" + ] + } +} \ No newline at end of file