@@ -3,10 +3,10 @@ output:
33 html_document :
44 keep_md : yes
55params :
6- projectId : !r 'syn1773109 '
7- nMonths : 2
8- useTeamGrouping : TRUE
9- aclTeamOrder : !r c(2224090, 3319054, 273957, 'syn1773109 ')
6+ projectId : !r 'syn2775243 '
7+ nMonths : !r NA
8+ useTeamGrouping : !r TRUE
9+ aclTeamOrder : !r c('syn2775243 ')
1010 queryDataFile : !r NA
1111---
1212
@@ -40,7 +40,18 @@ qDownloadTemplate <- 'select CLIENT,ENTITY_ID,CONVERT(AR.TIMESTAMP, CHAR) AS TIM
4040config <- yaml.load_file("~/datawarehouse_config.yml")
4141
4242projectId <- gsub("syn", "", params$projectId)
43- nMonths <- params$nMonths
43+ proj <- synGet(params$projectId)
44+
45+
46+ if (is.na(params$nMonths)) {
47+ startDate <- lubridate::as_date(proj@properties$createdOn)
48+ thisDate <- lubridate::floor_date(lubridate::today(), "month")
49+ thisDate <- thisDate - lubridate::period(1, "months")
50+ nMonths <- interval(startDate, thisDate) %/% months(1)
51+ } else {
52+ nMonths <- params$nMonths
53+ }
54+
4455useTeamGrouping <- params$useTeamGrouping
4556aclTeamOrder <- params$aclTeamOrder
4657
@@ -52,7 +63,6 @@ con <- dbConnect(MySQL(),
5263
5364timestampBreaksDf <- makeDateBreaks(nMonths) %>% dplyr::arrange(date)
5465
55- proj <- synGet(params$projectId)
5666
5767```
5868
@@ -125,27 +135,36 @@ queryData %>%
125135
126136There are ` r length(setdiff(unique(queryData$userName), c("anonymous"))) ` active registered Synapse users in this time period. Of these, ` r multiMonthVisits(queryData) %>% nrow ` users were active in the project in at least two different months.
127137
138+ ## Project page views
139+
140+ Count of the number of page views of the main project Wiki (` r params$projectId ` ) per month.
141+
128142``` {r}
129143projectPageViews <- queryData %>% filter(recordType=='pageview', NODE_TYPE=='project', id==projectId)
130144
131- if (useTeamGrouping) {
132- projectPageViewsCount <- projectPageViews %>%
133- dplyr::filter(recordType == 'pageview') %>%
134- dplyr::count(teamName, dateGrouping) %>%
135- reshape2::dcast(teamName ~ dateGrouping, fun.aggregate = sum)
136- } else {
137- projectPageViewsCount <- projectPageViews %>%
138- dplyr::filter(recordType == 'pageview') %>%
139- dplyr::mutate(teamName='All') %>%
140- dplyr::count(teamName, dateGrouping) %>%
141- reshape2::dcast(teamName ~ dateGrouping)
145+ if (nrow(projectPageViews) > 0) {
146+ if (useTeamGrouping) {
147+ projectPageViewsCount <- projectPageViews %>%
148+ dplyr::filter(recordType == 'pageview') %>%
149+ dplyr::count(teamName, dateGrouping) %>%
150+ reshape2::dcast(teamName ~ dateGrouping, fun.aggregate = sum)
151+ } else {
152+ projectPageViewsCount <- projectPageViews %>%
153+ dplyr::filter(recordType == 'pageview') %>%
154+ dplyr::mutate(teamName='All') %>%
155+ dplyr::count(teamName, dateGrouping) %>%
156+ reshape2::dcast(teamName ~ dateGrouping)
157+ }
158+
159+ projectPageViewsCount %>% knitr::kable()
142160}
143161
144- projectPageViewsCount %>% knitr::kable()
145-
146162```
147163
148164#### Page views per month
165+
166+ Count of the page views of any page (Wiki or entity) in the entire project per month.
167+
149168``` {r loadpermonth, include=TRUE, eval=TRUE}
150169if (useTeamGrouping) {
151170 dateGroupingCount <- queryData %>%
@@ -164,47 +183,62 @@ dateGroupingCount %>% knitr::kable()
164183```
165184
166185#### Page views per day
186+
187+ Plot of the page views of any page (Wiki or entity) in the entire project per day.
188+
167189``` {r plotperday, fig.width=20, fig.height=6, include=TRUE, eval=TRUE}
168190perdayCount <- countByDay(queryData %>% filter(recordType == 'pageview'),
169191 useTeamGrouping)
170- plotByDay(perdayCount, useTeamGrouping)
192+
193+ if (nrow(perdayCount) > 0) {
194+ plotByDay(perdayCount, useTeamGrouping)
195+ }
171196```
172197
173- #### Entity page views (top 100 with more than 5 views)
198+ #### Entity page views
199+
200+ The top 50 Files or Folders with at least 5 views.
201+
174202``` {r include=TRUE, eval=TRUE}
175203### Data
176204tmp <- queryData %>%
177205 dplyr::filter(recordType == 'pageview') %>%
178206 dplyr::count(id, NAME, NODE_TYPE) %>%
179207 dplyr::filter(n >= 5, !stringr::str_detect(id, "acl"))
180208
181- dataaccessCount1 <- queryData %>%
182- dplyr::filter(recordType == 'pageview') %>%
183- dplyr::filter(id %in% tmp$id) %>%
184- dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
185- dplyr::ungroup() %>%
186- reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
187- dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
209+ if (nrow(tmp) > 0) {
210+ dataaccessCount1 <- queryData %>%
211+ dplyr::filter(recordType == 'pageview') %>%
212+ dplyr::filter(id %in% tmp$id) %>%
213+ dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
214+ dplyr::ungroup() %>%
215+ reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
216+ dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
188217 # dplyr::mutate(name=sprintf("[%s](https://www.synapse.org/#!Synapse:syn%s)", NAME, id))
189-
190-
191- dataaccessCount2 <- queryData %>%
192- dplyr::filter(recordType == 'pageview') %>%
193- dplyr::filter(id %in% tmp$id) %>%
194- dplyr::count(id, NAME, NODE_TYPE) %>%
195- dplyr::ungroup() %>%
196- dplyr::arrange(dplyr::desc(n))
197-
198- dataaccessCount <- dataaccessCount1 %>% left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
199- dplyr::arrange(dplyr::desc(n)) %>%
200- head(50) %>%
201- dplyr::rename(total=n) %>%
202- dplyr::select(name, everything(), total, -id, -NAME)
203-
204- dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
218+
219+
220+ dataaccessCount2 <- queryData %>%
221+ dplyr::filter(recordType == 'pageview') %>%
222+ dplyr::filter(id %in% tmp$id) %>%
223+ dplyr::count(id, NAME, NODE_TYPE) %>%
224+ dplyr::ungroup() %>%
225+ dplyr::arrange(dplyr::desc(n))
226+
227+ dataaccessCount <- dataaccessCount1 %>%
228+ left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
229+ dplyr::arrange(dplyr::desc(n)) %>%
230+ head(50) %>%
231+ dplyr::rename(total=n) %>%
232+ dplyr::select(name, everything(), total, -id, -NAME)
233+
234+ dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
235+ }
205236```
206237
207238#### Entity downloads (top 100 with more than 5 views)
239+
240+ The top 50 Files or Folders with at least 5 views.
241+
208242``` {r include=TRUE, eval=TRUE}
209243### Data
210244tmp <- queryData %>%
@@ -213,29 +247,30 @@ tmp <- queryData %>%
213247 dplyr::filter(n >= 5, !stringr::str_detect(id, "acl"))
214248
215249if (nrow(tmp) > 0) {
216- dataaccessCount1 <- queryData %>%
217- dplyr::filter(recordType == 'download') %>%
218- dplyr::filter(id %in% tmp$id) %>%
219- dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
220- dplyr::ungroup() %>%
221- reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
222- dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
250+ dataaccessCount1 <- queryData %>%
251+ dplyr::filter(recordType == 'download') %>%
252+ dplyr::filter(id %in% tmp$id) %>%
253+ dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
254+ dplyr::ungroup() %>%
255+ reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
256+ dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
223257 # dplyr::mutate(name=sprintf("[%s](https://www.synapse.org/#!Synapse:syn%s)", NAME, id))
224-
225-
226- dataaccessCount2 <- queryData %>%
227- dplyr::filter(recordType == 'download') %>%
228- dplyr::filter(id %in% tmp$id) %>%
229- dplyr::count(id, NAME, NODE_TYPE) %>%
230- dplyr::ungroup() %>%
231- dplyr::arrange(dplyr::desc(n))
232-
233- dataaccessCount <- dataaccessCount1 %>% left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
234- dplyr::arrange(dplyr::desc(n)) %>%
235- head(50) %>%
236- dplyr::rename(total=n) %>%
237- dplyr::select(name, everything(), total, -id, -NAME)
238-
239- dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
258+
259+
260+ dataaccessCount2 <- queryData %>%
261+ dplyr::filter(recordType == 'download') %>%
262+ dplyr::filter(id %in% tmp$id) %>%
263+ dplyr::count(id, NAME, NODE_TYPE) %>%
264+ dplyr::ungroup() %>%
265+ dplyr::arrange(dplyr::desc(n))
266+
267+ dataaccessCount <- dataaccessCount1 %>%
268+ left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
269+ dplyr::arrange(dplyr::desc(n)) %>%
270+ head(50) %>%
271+ dplyr::rename(total=n) %>%
272+ dplyr::select(name, everything(), total, -id, -NAME)
273+
274+ dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
240275}
241276```
0 commit comments