Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversion for snowflake ids from POSIXct #154

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Version: 0.3.4
Authors@R:
c(person("David", "Schoch", , "david@schochastics.net", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2952-4812")),
person("Chung-hong", "Chan", ,"chainsawtiney@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0002-6232-7530")),
person("Johannes", "Gruber", ,"JohannesB.Gruber@gmail.com", role = c("ctb"), comment = c(ORCID = "0000-0001-9177-1772")))
person("Johannes", "Gruber", ,"JohannesB.Gruber@gmail.com", role = c("ctb"), comment = c(ORCID = "0000-0001-9177-1772")),
person("Tim", "Schatto-Eckrodt", ,"kudusch@posteo.de", role = c("ctb"), comment = c(ORCID = "0000-0003-1658-4373")))
Description: An implementation of calls designed to collect and organize Mastodon data via its Application Program Interfaces (API), which can be found at the following URL: <https://docs.joinmastodon.org/>.
License: MIT + file LICENSE
URL: https://gesistsa.github.io/rtoot/, https://github.com/gesistsa/rtoot/
Expand Down
14 changes: 11 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,23 @@
return(passFun(prompt = prompt))
}

handle_id <- function(x) {
## Convert x to snowflake id if it is POSIXct
if (is(x, "POSIXct")) {
return(as.numeric(x) * (2^16) * 1000)

Check warning on line 243 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L243

Added line #L243 was not covered by tests
}
x
}

handle_params <- function(params, max_id, since_id, min_id) {
if (!missing(max_id)) {
params$max_id <- max_id
params$max_id <- handle_id(max_id)
}
if (!missing(since_id)) {
params$since_id <- since_id
params$since_id <- handle_id(since_id)
}
if (!missing(min_id)) {
params$min_id <- min_id
params$min_id <- handle_id(min_id)
}
params
}
Expand Down
Loading