Skip to content

Commit 93ca0d7

Browse files
authored
usage metrics dashboard: use connectapi's get_usage() implementation (#281)
* remove old custom get_usage implementation * simplify implementation
1 parent 9ee38eb commit 93ca0d7

File tree

6 files changed

+24
-75
lines changed

6 files changed

+24
-75
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Package: usage-metrics-dashboard
2-
Version: 1.0.8
2+
Version: 1.0.9

extensions/usage-metrics-dashboard/R/get_usage.R

Lines changed: 0 additions & 48 deletions
This file was deleted.

extensions/usage-metrics-dashboard/app.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,19 @@ server <- function(input, output, session) {
605605

606606
usage_data_meta <- reactive({
607607
req(active_user_role %in% c("administrator", "publisher"))
608-
dat <- get_usage(
608+
from <- as.POSIXct(paste(date_range()$from, "00:00:00"), tz = "")
609+
to <- as.POSIXct(paste(date_range()$to, "23:59:59"), tz = "")
610+
611+
usage_list <- get_usage(
609612
client,
610-
from = date_range()$from,
611-
to = date_range()$to
613+
from = from,
614+
to = to
612615
)
616+
usage_tbl <- as_tibble(usage_list) |>
617+
filter(!grepl("^ContentHealthMonitor/", user_agent)) |>
618+
select(user_guid, content_guid, timestamp)
613619
list(
614-
data = dat,
620+
data = usage_tbl,
615621
last_updated = Sys.time()
616622
)
617623
}) |>

extensions/usage-metrics-dashboard/manifest.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -491,33 +491,34 @@
491491
"Type": "Package",
492492
"Package": "connectapi",
493493
"Title": "Utilities for Interacting with the 'Posit Connect' Server API",
494-
"Version": "0.7.0",
494+
"Version": "0.8.0",
495495
"Authors@R": "c(\n person(given = \"Toph\",\n family = \"Allen\",\n role = c(\"aut\", \"cre\"),\n email = \"[email protected]\"),\n person(given = \"Neal\",\n family = \"Richardson\",\n role = c(\"aut\")),\n person(given = \"Sean\",\n family = \"Lopp\",\n role = c(\"aut\")),\n person(given = \"Cole\",\n family = \"Arendt\",\n role = c(\"aut\")),\n person(given = \"Posit, PBC\",\n role = c(\"cph\", \"fnd\")))",
496496
"Description": "Provides a helpful 'R6' class and methods for interacting with\n the 'Posit Connect' Server API along with some meaningful utility functions\n for regular tasks. API documentation varies by 'Posit Connect' installation\n and version, but the latest documentation is also hosted publicly at\n <https://docs.posit.co/connect/api/>.",
497497
"License": "MIT + file LICENSE",
498498
"URL": "https://posit-dev.github.io/connectapi/,\nhttps://github.com/posit-dev/connectapi",
499499
"BugReports": "https://github.com/posit-dev/connectapi/issues",
500500
"Imports": "bit64, fs, glue, httr, mime, jsonlite, lifecycle, magrittr,\npurrr, R6, rlang (>= 0.4.2), tibble, uuid, vctrs (>= 0.3.0),\nbase64enc",
501-
"Suggests": "covr, dbplyr, dplyr, ggplot2, gridExtra, httptest, knitr,\nlubridate, progress, rmarkdown, rprojroot, rsconnect, spelling,\ntestthat, webshot2, withr",
501+
"Suggests": "covr, dbplyr, dplyr, ggplot2, gridExtra, httptest, knitr,\nlubridate, progress, rmarkdown, rprojroot, rsconnect, spelling,\ntestthat, tidyr, webshot2, withr",
502502
"VignetteBuilder": "knitr",
503503
"Encoding": "UTF-8",
504504
"Language": "en-US",
505505
"RoxygenNote": "7.3.2",
506506
"Config/testthat/edition": "3",
507+
"Collate": "'audits.R' 'browse.R' 'connect.R' 'connectapi-package.R'\n'connectapi.R' 'content.R' 'deploy.R' 'get.R' 'git.R'\n'groups.R' 'integrations.R' 'lazy.R' 'page.R' 'parse.R'\n'promote.R' 'ptype.R' 'remote.R' 'runtime-caches.R'\n'schedule.R' 'tags.R' 'utils.R' 'thumbnail.R' 'user.R'\n'utils-ci.R' 'utils-pipe.R' 'variant.R'",
507508
"NeedsCompilation": "no",
508-
"Packaged": "2025-03-27 15:47:12 UTC; toph",
509+
"Packaged": "2025-07-30 21:46:47 UTC; toph",
509510
"Author": "Toph Allen [aut, cre],\n Neal Richardson [aut],\n Sean Lopp [aut],\n Cole Arendt [aut],\n Posit, PBC [cph, fnd]",
510511
"Maintainer": "Toph Allen <[email protected]>",
511512
"Repository": "RSPM",
512-
"Date/Publication": "2025-03-27 16:10:02 UTC",
513-
"Built": "R 4.3.0; ; 2025-03-28 04:43:28 UTC; unix",
513+
"Date/Publication": "2025-07-30 22:00:11 UTC",
514+
"Built": "R 4.3.0; ; 2025-07-31 10:36:47 UTC; unix",
514515
"RemoteType": "standard",
515516
"RemoteRef": "connectapi",
516517
"RemotePkgRef": "connectapi",
517518
"RemoteRepos": "https://packagemanager.posit.co/cran/latest",
518519
"RemoteReposName": "CRAN",
519520
"RemotePkgPlatform": "aarch64-apple-darwin20",
520-
"RemoteSha": "0.7.0"
521+
"RemoteSha": "0.8.0"
521522
}
522523
},
523524
"cpp11": {
@@ -3036,10 +3037,7 @@
30363037
},
30373038
"files": {
30383039
"app.R": {
3039-
"checksum": "5555b67b7f82d2dbc90b3a36260ceeac"
3040-
},
3041-
"R/get_usage.R": {
3042-
"checksum": "1231f3eece53466dd1ff0867f1019bb0"
3040+
"checksum": "e065053068e111b4896b49f7d0875680"
30433041
},
30443042
"R/integrations.R": {
30453043
"checksum": "2b495c74b5987a2c318bcd80a0c2be8f"
@@ -3054,7 +3052,7 @@
30543052
"checksum": "c0599c7d23181ccb7b2e1a02db85114b"
30553053
},
30563054
"renv.lock": {
3057-
"checksum": "05865206c04be53631ca32658836ad2a"
3055+
"checksum": "1503687e203d1f5db7299f8a4a28ce06"
30583056
},
30593057
"www/styles.css": {
30603058
"checksum": "7ea30e3cc044a3221877a503b0e1ee7d"
@@ -3071,6 +3069,6 @@
30713069
"requiredFeatures": [
30723070
"OAuth Integrations"
30733071
],
3074-
"version": "1.0.8"
3072+
"version": "1.0.9"
30753073
}
30763074
}

extensions/usage-metrics-dashboard/renv.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@
467467
},
468468
"connectapi": {
469469
"Package": "connectapi",
470-
"Version": "0.7.0",
470+
"Version": "0.8.0",
471471
"Source": "Repository",
472472
"Type": "Package",
473473
"Title": "Utilities for Interacting with the 'Posit Connect' Server API",
@@ -508,6 +508,7 @@
508508
"rsconnect",
509509
"spelling",
510510
"testthat",
511+
"tidyr",
511512
"webshot2",
512513
"withr"
513514
],
@@ -516,6 +517,7 @@
516517
"Language": "en-US",
517518
"RoxygenNote": "7.3.2",
518519
"Config/testthat/edition": "3",
520+
"Collate": "'audits.R' 'browse.R' 'connect.R' 'connectapi-package.R' 'connectapi.R' 'content.R' 'deploy.R' 'get.R' 'git.R' 'groups.R' 'integrations.R' 'lazy.R' 'page.R' 'parse.R' 'promote.R' 'ptype.R' 'remote.R' 'runtime-caches.R' 'schedule.R' 'tags.R' 'utils.R' 'thumbnail.R' 'user.R' 'utils-ci.R' 'utils-pipe.R' 'variant.R'",
519521
"NeedsCompilation": "no",
520522
"Author": "Toph Allen [aut, cre], Neal Richardson [aut], Sean Lopp [aut], Cole Arendt [aut], Posit, PBC [cph, fnd]",
521523
"Maintainer": "Toph Allen <[email protected]>",

extensions/usage-metrics-dashboard/tests/testthat/test_get_usage.R

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)