library(connectwidgets)
library(dplyr, warn.conflicts = FALSE)
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
client <- connect(
# server = Sys.getenv("CONNECT_SERVER"),
# api_key = Sys.getenv("CONNECT_API_KEY")
)
all_content <- client %>%
content()
glimpse(all_content)
#> Rows: 1,213
#> Columns: 15
#> $ id <int> 3979, 4603, 4602, 5061, 5015, 5054, 5055, 5052, 5030,…
#> $ guid <chr> "ca22a1f6-bab5-4fc0-8f38-ed8021be41f5", "e7c26684-ec4…
#> $ name <chr> "github-issues-connect", "group-info", "user-info", "…
#> $ title <chr> NA, "group-info", "user-info", "plumbertabeau", "RSC+…
#> $ description <chr> "A table pin with 19718 rows and 10 columns.", "Resul…
#> $ app_mode <chr> "static", "static", "static", "api", "static", "api",…
#> $ content_category <chr> "pin", "pin", "pin", "api", "site", "api", "", "", "s…
#> $ url <chr> "https://rsc.radixu.com/content/ca22a1f6-bab5-4fc0-8f…
#> $ owner_guid <chr> "1d6cc041-eb11-411e-810e-718508cde25b", "0fc96747-ec9…
#> $ owner_username <chr> "brian", "kelly.obriant", "kelly.obriant", "david", "…
#> $ owner_first_name <chr> "Brian", "Kelly", "Kelly", "E. David", "Aron", "Toph"…
#> $ owner_last_name <chr> "Smith", "@RStudio", "@RStudio", "Aja", "Atkins", "Al…
#> $ tags <list> [<data.frame[2 x 5]>], [<data.frame[1 x 5]>], [<data…
#> $ created_time <dttm> 2020-04-03 17:54:27, 2020-12-05 02:37:30, 2020-12-05…
#> $ updated_time <dttm> 2021-07-28 07:03:10, 2021-07-28 07:00:41, 2021-07-28…
sample_content <- all_content %>%
arrange(desc(updated_time)) %>%
slice_head(n = 100)
content()
content()
returns a data frame with the following columns:
-
id
- Auto-incrementing identifier for each content item (legacy)
-
guid
- Unique identifier for each content item (preferred)
-
app_mode
- The type of the content item (examples: shiny
, rmd-static
, static
, python-dash
, etc.)
-
content_category
- For static
app modes, the specific category of content (examples: site
, plot
, pin
, etc.)
-
name
- The name of the content item as set at initial publishing
-
title
- The user-provided title of the content item
-
description
- The user-provided description of the content item
-
url
- The URL to the content item
-
owner_guid
- Unique identifier of the owner of the content item
-
owner_username
- Username of the owner of the content item
-
owner_first_name
- First name of the owner of the content item
-
owner_last_name
- Last name of the owner of the content item
-
tags
- A data frame of the tags associated with the content item, with the following columns: id
, name
, parent_id
, created_time
, updated_time
.
-
created_time
- The timestamp at which the content item was created
-
updated_time
- The timestamp at which the content item was last updated
The data frame contains one row for each item visible to the requesting user. For users in an “administrator” role, that will be all content items.
Filtering Content
We provide helper functions to filter by both owners and tags.
by_tags()
- Filters the data frame to only include content that has been tagged with the specified tag name(s). You can pass a single tag name or a vector of tag names. by_tag
is provided as an alias for readability when using a single tag.
by_owners()
- Filters the data frame to only include content with the specified owner(s) by username. You can pass a single username or a vector of usernames. by_owner
is provided as an alias for readability when using a single username.
all_content %>%
by_tag("Audit Reports")
#> # A tibble: 6 x 15
#> id guid name title description app_mode content_category url owner_guid
#> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 4875 7cbd… Audi… Audi… Using the … rmd-sta… "" http… 0fc96747-…
#> 2 4619 b191… tag-… Tag … List all t… rmd-sta… "" http… 0fc96747-…
#> 3 4618 4348… acl-… Cont… Generate a… rmd-sta… "" http… 0fc96747-…
#> 4 4597 6a8f… cont… Basi… List all c… rmd-sta… "" http… 0fc96747-…
#> 5 4596 3f7a… vani… Vani… List all d… rmd-sta… "" http… 0fc96747-…
#> 6 4595 5687… envi… R an… R and Pyth… rmd-sta… "" http… 0fc96747-…
#> # … with 6 more variables: owner_username <chr>, owner_first_name <chr>,
#> # owner_last_name <chr>, tags <list>, created_time <dttm>,
#> # updated_time <dttm>
Since all_content
is a tibble()
, you can also manipulate it with dplyr:
all_content %>%
filter(updated_time >= "2021-01-01") %>%
arrange(created_time)
#> # A tibble: 77 x 15
#> id guid name title description app_mode content_category url
#> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 1440 d7bf0e… cs_rep… cs_re… "" rmd-sta… "" https:…
#> 2 1890 be63ca… rmd rmd4 "This rmd is … rmd-sta… "" https:…
#> 3 3724 b5e57e… team-d… Team-… "" static "" https:…
#> 4 3979 ca22a1… github… <NA> "A table pin … static "pin" https:…
#> 5 4364 9ffbbd… shiny-… shiny… "" shiny "" https:…
#> 6 4602 e21598… user-i… user-… "Results pull… static "pin" https:…
#> 7 4603 e7c266… group-… group… "Results pull… static "pin" https:…
#> 8 4630 f12eb8… top-5-… top-5… "" python-… "" https:…
#> 9 4631 68c9b2… top-5-… top-5… "" python-… "" https:…
#> 10 4650 ebdea3… reticu… retic… "" static "" https:…
#> # … with 67 more rows, and 7 more variables: owner_guid <chr>,
#> # owner_username <chr>, owner_first_name <chr>, owner_last_name <chr>,
#> # tags <list>, created_time <dttm>, updated_time <dttm>