-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmasterView.R
More file actions
38 lines (30 loc) · 1.14 KB
/
masterView.R
File metadata and controls
38 lines (30 loc) · 1.14 KB
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
masterView <- function(source = NULL, expand = FALSE){
con <- RPostgres::dbConnect(
RPostgres::Postgres(),
dbname = "d629vjn37pbl3l",
host = "ec2-3-209-200-73.compute-1.amazonaws.com",
port = 5432,
user = "reason_readonly",
password = "p88088bd28ea68027ee96c65996f7ea3b56db0e27d7c9928c05edc6c23ef2bc27",
sslmode = "require")
# define the query to retrieve the plan data
query <- paste("select * from",
if(isTRUE(expand)){paste("plan_attribute")}
else{paste("master_priority_view")}
)
result <- RPostgres::dbSendQuery(con, query)
#RPostgres::dbBind(result, list(1))
all_data <- RPostgres::dbFetch(result) %>%
janitor::clean_names()
RPostgres::dbClearResult(result)
RPostgres::dbDisconnect(con)
all_data <- data.table(all_data)
if(is.null(source)){
all_data <- data.table(all_data)
}else if(!is.null(source) & !isTRUE(expand)){
all_data <- all_data[ data_source_name == source]
}else if(!is.null(source) & source == "Reason" & isTRUE(expand)){
all_data <- all_data[ data_source_id == 3]}
else{all_data <- data.table(all_data)
}
}