-
Notifications
You must be signed in to change notification settings - Fork 13
/
global.R
86 lines (76 loc) · 3.28 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
### Packages
rm(list = ls())
library(shiny)
library(shinydashboard)
library(ggplot2)
library(dplyr)
library(dbplyr)
library(DT)
library(RSQLite)
library(shinyWidgets)
library(stringr)
library(shinyjs)
db.file <- "db.sqlite3"
challenge_names <- c("Dahu", "Cichlid")
init_db <- function() {
## get username
name <- readline(prompt = "User name: ")
## get mdp
password <- readline(prompt = "User password: ")
password.hash <- digest::digest(paste0("SSMPG2017", password), algo = "md5")
## write in table
db <- RSQLite::dbConnect(RSQLite::SQLite(), dbname = db.file)
dplyr::db_insert_into(db, "user", tibble::tibble(name = name, password = password.hash))
dplyr::db_insert_into(con = db,
table = "submission",
values = tibble::tibble(name = name,
date = as.character(Sys.time()),
challenge = "1",
dataset = "Training set",
methods = "None",
candidates = "0",
regions = "0")
)
dplyr::db_insert_into(con = db,
table = "submission",
values = tibble::tibble(name = name,
date = as.character(Sys.time()),
challenge = "1",
dataset = "Evaluation set",
methods = "None",
candidates = "0",
regions = "0")
)
dplyr::db_insert_into(con = db,
table = "submission",
values = tibble::tibble(name = name,
date = as.character(Sys.time()),
challenge = "2",
dataset = "Real",
methods = "None",
candidates = "0",
regions = "None")
)
RSQLite::dbDisconnect(db)
}
add_submission <- function(user.name,
password,
challenge,
dataset,
methods,
candidates,
regions) {
db <- RSQLite::dbConnect(RSQLite::SQLite(), dbname = db.file)
## add submission
dplyr::db_insert_into(con = db,
table = "submission",
values = tibble::tibble(name = user.name,
date = as.character(Sys.time()),
challenge = challenge,
dataset = dataset,
methods = methods,
candidates = candidates,
regions = regions)
)
RSQLite::dbDisconnect(db)
}