Skip to content
Open
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
5 changes: 3 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
[.]js$
^\.github$
^CITATION\.cff$
^\.positai$
^\.claude$
^_pkgdown\.yml$
^docs$
^pkgdown$
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: windows-latest, r: '4.1.0'}
- {os: ubuntu-latest, r: '3.6.3'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ rsconnect/

# Postman collection exports
tests/postman/*.json

# PositAI (default RStudio)
.positai
docs
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ Description: Provides API endpoints to the European Tracking Network.
License: MIT + file LICENSE
URL: https://github.com/inbo/etnservice
BugReports: https://github.com/inbo/etnservice/issues
Depends:
R (>= 4.1.0)
Imports:
arrow,
assertthat,
DBI,
dplyr,
glue,
httr,
jsonlite,
lubridate,
methods,
odbc,
Expand All @@ -33,7 +32,6 @@ Imports:
stringr,
utils
Suggests:
jsonlite,
purrr,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export(list_scientific_names)
export(list_station_names)
export(list_tag_serial_numbers)
export(validate_login)
export(write_dwc)
importFrom(dplyr,"%>%")
importFrom(dplyr,.data)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
Expand Down
5 changes: 2 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# etnservice (development version)
- The function `write_dwc()` has been updated in the `etn` package and is no longer needed in `etnservice`. (#141)
- The `jsonlite` package is no longer a direct dependency, it is only used by a maintenance script. (#144)
- etnservice now relies on R >= 4.1.0 and uses base pipes (`|>` rather than `%>%`) (#151).
- etnservice now has a pkgdown website: [inbo.github.io/etnservice/](https://inbo.github.io/etnservice/).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either:

  • Link pkgdown website
  • Write the URL as <https://inbo.github.io/etnservice/>

Also useful to add the PR number at the end in (139) before the closing .


# etnservice 0.6.0
- Added `get_receiver_logs()` to fetch receiver logs from the database. The data is returned as a tibble with a column with logs in JSON format. (#117)

Expand Down
1 change: 1 addition & 0 deletions R/etnservice-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom dplyr %>%
#' @importFrom dplyr .data
#' @importFrom dplyr distinct
#' @importFrom dplyr filter
Expand Down
2 changes: 1 addition & 1 deletion R/get_acoustic_deployments.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ get_acoustic_deployments <- function(

# Sort data
deployments <-
deployments |>
deployments %>%
dplyr::arrange(
.data$acoustic_project_code,
factor(.data$station_name, levels = list_station_names(credentials)),
Expand Down
2 changes: 1 addition & 1 deletion R/get_acoustic_detections.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ get_acoustic_detections <- function(credentials = list(

# Sort data (faster than in SQL)
detections <-
detections |>
detections %>%
dplyr::arrange(
factor(.data$acoustic_tag_id, levels = list_acoustic_tag_ids(credentials)),
.data$date_time
Expand Down
3 changes: 1 addition & 2 deletions R/get_acoustic_detections_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ get_acoustic_detections_page <- function(credentials = list(
# Apply mapping -----
if (!count) {
# No need to apply mapping if we're only returning the number of records
returned_page <-
returned_page |>
returned_page <- returned_page %>%
dplyr::transmute(
detection_id = .data$detection_id_pk,
date_time = .data$datetime,
Expand Down
2 changes: 1 addition & 1 deletion R/get_acoustic_projects.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ get_acoustic_projects <- function(credentials = list(

# Sort data
projects <-
projects |>
projects %>%
dplyr::arrange(.data$project_code)

dplyr::as_tibble(projects)
Expand Down
2 changes: 1 addition & 1 deletion R/get_acoustic_receivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ get_acoustic_receivers <- function(credentials = list(

# Sort data
receivers <-
receivers |>
receivers %>%
dplyr::arrange(.data$receiver_id)

# Close connection
Expand Down
2 changes: 1 addition & 1 deletion R/get_animal_projects.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ get_animal_projects <- function(credentials = list(

# Sort data
projects <-
projects |>
projects %>%
dplyr::arrange(.data$project_code)

dplyr::as_tibble(projects)
Expand Down
20 changes: 10 additions & 10 deletions R/get_animals.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,24 @@ get_animals <- function(credentials = list(

# Collapse tag information, to obtain one row = one animal
tag_cols <-
animals |>
dplyr::select(dplyr::starts_with("tag"), dplyr::starts_with("acoustic_tag_id")) |>
animals %>%
dplyr::select(dplyr::starts_with("tag"), dplyr::starts_with("acoustic_tag_id")) %>%
names()
other_cols <-
animals |>
dplyr::select(-dplyr::starts_with("tag"), -dplyr::starts_with("acoustic_tag_id")) |>
animals %>%
dplyr::select(-dplyr::starts_with("tag"), -dplyr::starts_with("acoustic_tag_id")) %>%
names()
animals <-
animals |>
dplyr::group_by_at(other_cols) |>
dplyr::summarize_at(tag_cols, paste, collapse = ",") |> # Collapse multiple tags by comma
dplyr::ungroup() |>
dplyr::mutate_at(tag_cols, gsub, pattern = "NA", replacement = "") |> # Use "" instead of "NA"
animals %>%
dplyr::group_by_at(other_cols) %>%
dplyr::summarize_at(tag_cols, paste, collapse = ",") %>% # Collapse multiple tags by comma
dplyr::ungroup() %>%
dplyr::mutate_at(tag_cols, gsub, pattern = "NA", replacement = "") %>% # Use "" instead of "NA"
dplyr::select(names(animals)) # Use the original column order

# Sort data
animals <-
animals |>
animals %>%
dplyr::arrange(
.data$animal_project_code,
.data$release_date_time,
Expand Down
2 changes: 1 addition & 1 deletion R/get_cpod_projects.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ get_cpod_projects <- function(credentials = list(

# Sort data
projects <-
projects |>
projects %>%
dplyr::arrange(.data$project_code)
# Close connection
DBI::dbDisconnect(connection)
Expand Down
2 changes: 1 addition & 1 deletion R/get_receiver_logs.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ get_receiver_logs <- function(credentials = list(

# Sort data
receiver_logs <-
receiver_logs |>
receiver_logs %>%
dplyr::arrange(factor(
.data$deployment_id, levels = list_deployment_ids(credentials)
))
Expand Down
2 changes: 1 addition & 1 deletion R/get_tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ get_tags <- function(credentials = list(

# Sort data
tags <-
tags |>
tags %>%
dplyr::arrange(factor(.data$tag_serial_number, levels = list_tag_serial_numbers(credentials)))

dplyr::as_tibble(tags)
Expand Down
4 changes: 2 additions & 2 deletions R/get_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ get_version <- function() {
# Get all functions from etnservice and their code
fn_names <- ls(envir = getNamespace("etnservice"))
fn_code <- purrr::map(fn_names,
~ get(.x, envir = getNamespace("etnservice"))) |>
purrr::map(deparse) |>
~ get(.x, envir = getNamespace("etnservice"))) %>%
purrr::map(deparse) %>%
purrr::set_names(fn_names)
# Calculate hashes for the functions, report on the installed version of
# etnservice
Expand Down
18 changes: 9 additions & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ check_credentials <- function(credentials) {
#' @family helper functions
#' @noRd
extract_temp_key <- function(response) {
response |>
httr::content(as = "text") |>
response %>%
httr::content(as = "text") %>%
stringr::str_extract("(?<=tmp\\/).{15}(?=\\/)")
}

Expand All @@ -188,13 +188,13 @@ extract_temp_key <- function(response) {
#' @noRd
#' @examples
#' \dontrun{
#' etn:::extract_temp_key(response) |> get_val()
#' etn:::extract_temp_key(response) %>% get_val()
#' }
#'
#' # using the opencpu test instance
#' api_url <- "https://cloud.opencpu.org/ocpu/library/stats/R/rnorm"
#' httr::POST(api_url, body = list(n = 10, mean = 5)) |>
#' extract_temp_key() |>
#' httr::POST(api_url, body = list(n = 10, mean = 5)) %>%
#' extract_temp_key() %>%
#' get_val(api_domain = "https://cloud.opencpu.org/ocpu")
get_val <- function(temp_key, api_domain = "https://opencpu.lifewatch.be") {
httr::GET(
Expand All @@ -203,9 +203,9 @@ get_val <- function(temp_key, api_domain = "https://opencpu.lifewatch.be") {
"tmp/{temp_key}/R/.val/rds",
.sep = "/"
)
) |>
httr::content(as = "raw") |>
rawConnection() |>
gzcon() |>
) %>%
httr::content(as = "raw") %>%
rawConnection() %>%
gzcon() %>%
readRDS()
}
Loading
Loading