Open iainmwallace opened 2 years ago
Posting the function I wrote to make a tag, with hierarchy, variable in the tag data. This may be useful if there is a desire to implement something similar.
get_tag_data_with_hierarchy <- function(client, sep = "/") {
tag_data <- connectapi::get_tag_data(client)
tag_data$name_hierarchy <- purrr::map_chr(
tag_data$id,
function(xx) {
pop_dat <- tag_data[tag_data$id == xx, ]
tmp_out <- pop_dat$name
# checking for multiple tag levels
while (!is.na(pop_dat$parent_id)) {
tmp_out <- glue::glue(
"{tag_data$name[tag_data$id == pop_dat$parent_id]}{sep}{tmp_out}"
)
pop_dat <- tag_data[tag_data$id == pop_dat$parent_id, ]
}
tmp_out
}
)
tag_data
}
Is it possible to retrieve the top level of a tag hierarchy? The tags function doesn't seem to return it.
For example if I have
Project
The tag function will only show project1 and project2 not Project
Thanks
Iain