Skip to content

Commit

Permalink
Ensure default dataset is newest available
Browse files Browse the repository at this point in the history
* closes #124
  • Loading branch information
jefferis committed Jun 18, 2020
1 parent 1db9ced commit 4c68405
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions R/fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,19 @@ check_dataset <-
dataset
}

# return available datasets sorted my descending modification time
# i.e. newest first
available_datasets <- function(conn=NULL, ...) {
conn=neuprint_login(conn)
ds=neuprint_datasets_memo(conn=conn, ...)
datasets <- names(ds)
if(length(datasets)==0) return(NULL) else datasets
if(length(ds)==0) return(NULL)
# find last modification times, filling missing values with na
lastmod = sapply(ds, function(x) {
lm = x[["last-mod"]]
if (nzchar(lm)) lm else NA_character_
})
# sort to return newest first
lastmod=sort(lastmod, na.last = TRUE, decreasing = TRUE)
datasets=names(lastmod)
datasets
}

0 comments on commit 4c68405

Please sign in to comment.