Skip to content

Commit df01edd

Browse files
author
Dominique Quatravaux
committed
[feature] Add some typings
1 parent 6be1bcb commit df01edd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

confluence.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
library(tidyverse)
44
library(archive)
55
library(xml2)
6+
library(bit64)
67

78
archive_path <- "/Users/quatrava/Downloads/ISAS-FSD-idevfsd-2025-03-28-11-36-24-881.xml.zip"
89

@@ -58,7 +59,16 @@ props_tibble <- function(objects_nodeset) {
5859
pkeys = xml_attr(props, 'name'),
5960
pvals = xml_text(props)) %>%
6061
pivot_wider(names_from = pkeys, values_from = pvals) %>%
61-
select(-row)
62+
select(-row) %>%
63+
mutate(across(any_of(c("position")) |
64+
ends_with("version", ignore.case = TRUE),
65+
as.integer),
66+
across(any_of(c("longValue")),
67+
as.integer64),
68+
across(any_of(c("contentStatus", "relationName", "targetType")),
69+
as.factor),
70+
across(ends_with("date", ignore.case = TRUE),
71+
parse_datetime))
6272
}
6373

6474
#' Format the “props” that have a `class` for each node in a nodeset, into a tibble
@@ -144,7 +154,8 @@ bodies <- {
144154
type = case_when(
145155
bodyType == 0 ~ "SpaceDescription",
146156
bodyType == 1 ~ "CustomContentEntityObject",
147-
bodyType == 2 ~ "PageEtc")) %>%
157+
bodyType == 2 ~ "PageEtc") %>%
158+
as_factor) %>%
148159
mutate(ns %>% classful_props_tibble)
149160
}
150161

0 commit comments

Comments
 (0)