-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate_db.R
More file actions
60 lines (43 loc) · 1.85 KB
/
Copy pathupdate_db.R
File metadata and controls
60 lines (43 loc) · 1.85 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# remove all objects in the global environment:
# rm(list = ls())
# ------------------------------------------------------------------------------
# Script to update an existing database from input prepared by UNHCR Geneva
# Author:
# Maarten-Jan Kallen <mj@bedatadriven.com>
# Instructions:
# Edit the values in the next section if desired and then source the file.
# ------------------------------------------------------------------------------
# database to be updated:
database.id <- 5158
database.description <- paste("Pilot 2016 - DB updated on", Sys.Date())
# Default values for the forms:
location.type <- "UNHCR-Tunisia-Sites"
reporting.frequency <- "monthly"
# Target details (dates in YYYY-MM-DD format):
target.properties <- list(
name = "zzz_OL",
fromDate = "2016-01-01",
toDate = "2016-12-31"
)
# Alternate URL in case of IP blocking
new.url <- "https://proxy.activityinfo.org"
activityInfoRootUrl(new.url)
executeCommand("UpdateEntity",
entityName = "UserDatabase",
id = database.id, changes =
list(fullName = database.description))
###################################################################
## Focus API variable
country.focus <- "Syrian%20Arab%20Republic"
year.focus <- "2016"
## External file - not shared on github -- where we have the login details for
source("login.R")
input <- list(
partners = paste0(api.unhcr,"query=Partners&YEAR=",year.focus,"&OPERATION=",country.focus),
output.indicators = paste0(api.unhcr,"query=PerfIndicators&YEAR=",year.focus,"&OPERATION=",country.focus),
budget.indicators = paste0(api.unhcr,"query=OutputBudget&YEAR=",year.focus,"&OPERATION=",country.focus)
)
###################################################################
# ------------------------------------------------------------------------------
action <- "update"
source("workflow.R")