Skip to content

Commit

Permalink
v3.0.0
Browse files Browse the repository at this point in the history
Merge branch 'beta3'

# Conflicts:
#	NEWS.md
#	R/motusUpdateTagDB.R
#	R/srvQuery.R
#	R/tagme.R
#	tests/testthat/test_server.R
  • Loading branch information
steffilazerte committed Oct 16, 2019
2 parents 943ef3c + 2dd9a09 commit c7a014b
Show file tree
Hide file tree
Showing 156 changed files with 1,991 additions and 3,647 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
^data-raw$
^.*\.Rproj$
^\.Rproj\.user$
RELEASE.R
RELEASE.R
^appveyor.yml$
^.*\SG-.*$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ nohup.out
.Rproj.user
.Rhistory
.RData
tests/spelling.R
15 changes: 7 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: motus
Type: Package
Version: 2.0.0
Version: 3.0.0
Title: Fetch and use data from the Motus Wildlife Tracking System
Description: Retrieve, filter, and visualize telemetry data from the Motus
Wildlife Tracking System http://motus.org.
Expand All @@ -14,28 +14,27 @@ Depends:
Imports:
DBI (>= 1.0.0),
dplyr (>= 0.8.1),
dbplyr (>= 1.4.0),
dbplyr (>= 1.4.2),
httr (>= 1.4.0),
geosphere (>= 1.5.7),
ggplot2 (>= 3.2.0),
gridExtra (>= 2.3),
jsonlite (>= 1.6),
lattice (>= 0.20.38),
lubridate (>= 1.7.4),
magrittr,
maptools (>= 0.9.5),
methods,
purrr (>= 0.3.0),
rlang (>= 0.3.1),
RSQLite (>= 2.1.1),
stringi (>= 1.4.3),
stringr (>= 1.4.0),
tidyr (>= 0.8.3),
magrittr
Suggests:
spelling,
ggmap (>= 3.0.0),
testthat,
roxygen2
RCurl,
roxygen2,
spelling,
testthat
License: GPL-3 + file LICENSE
Date: 2019-03-28
RoxygenNote: 6.1.1
Expand Down
36 changes: 1 addition & 35 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,73 +1,39 @@
# Generated by roxygen2: do not edit by hand

S3method("$",safeSQL)
S3method(print,safeSQL)
export("%>%")
export(":=")
export(.data)
export(RL)
export(activity)
export(checkVersion)
export(clarify)
export(createRunsFilter)
export(dbInsertOrReplace)
export(deleteRunsFilter)
export(filterByActivity)
export(getDBFilename)
export(getLotekModel)
export(getMotusDBSrc)
export(getRuns)
export(getRunsFilterID)
export(getRunsFilters)
export(listRunsFilters)
export(makeAllambigsView)
export(makeAlltagsView)
export(makeSimpletagsView)
export(metadata)
export(motusLogout)
export(motus_vars)
export(nodeData)
export(plotAllTagsCoord)
export(plotAllTagsSite)
export(plotDailySiteSum)
export(plotRouteMap)
export(plotSite)
export(plotSiteSig)
export(plotTagSig)
export(safeSQL)
export(simSiteDet)
export(siteSum)
export(siteSumDaily)
export(siteTrans)
export(sqliteToRDS)
export(srvAPIinfo)
export(srvAuth)
export(srvBatchesForAll)
export(srvBatchesForReceiver)
export(srvBatchesForTagProject)
export(srvDeviceIDForReceiver)
export(srvGPSforReceiver)
export(srvGPSforTagProject)
export(srvHitsForReceiver)
export(srvHitsForTagProject)
export(srvMetadataForReceivers)
export(srvMetadataForTags)
export(srvProjectAmbiguitiesForTagProject)
export(srvPulseCountsforReceiver)
export(srvReceiversForProject)
export(srvRecvMetadataForProjects)
export(srvRunsForReceiver)
export(srvRunsForTagProject)
export(srvSizeOfUpdateForReceiver)
export(srvSizeOfUpdateForTagProject)
export(srvTagMetadataForProjects)
export(srvTagsForAmbiguities)
export(sunRiseSet)
export(tagSum)
export(tagSumSite)
export(tagme)
export(tellme)
export(timeToSunriset)
export(updateMotusDb)
export(writeRunsFilter)
importFrom(magrittr,"%>%")
importFrom(rlang,":=")
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# motus 3.0.0 (2019-10-16)

### Big Changes
* Switch to data version 2
* Includes new CTT antennas
* Includes `nodeData` and `nodeDeps` tables for node related data and metadata.

### Small Changes
* Replace all `cat()` with `message()` (now suppressible)
* Add `recvUtcOffset` and `tsCorrected` to `alltags` view
* Add `gpsID` to `gps` table, `gpsID` is now the primary key and index

### Bug fixes
* Fixed bug where `tagme(..., countOnly = TRUE)` failed

# motus 2.0.0 (2019-08-12)

### Big Changes
Expand Down
2 changes: 1 addition & 1 deletion R/Motus.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' \item{myProjects}{project IDs for user at motus.org}
#' }
#'
#' @export
#' @noRd
#'
#' @author John Brzustowski \email{jbrzusto@@REMOVE_THIS_PART_fastmail.fm}

Expand Down
65 changes: 0 additions & 65 deletions R/RL.R

This file was deleted.

79 changes: 21 additions & 58 deletions R/activity.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#' Add/update batch activity
#'
#' Download or resume a download of the 'activity' table in an existing Motus
#' Download or resume a download of the `activity` table in an existing Motus
#' database. Batch activity refers to the number of hits detected during a given
#' batch. Batches with large numbers of hits may indicate interference and thus
#' unreliable hits.
#'
#' @param src src_sqlite object representing the database
#' @param resume Logical. Resume a download? Otherwise the activity table is
#' @param resume Logical. Resume a download? Otherwise the `activity` table is
#' removed and the download is started from the beginning.
#'
#' @details This function is automatically run by the [tagme()] function with
#' `resume = TRUE`.
#'
#' If an 'activity' table doesn't exist, it will be created prior to
#' downloading. If there is an existing 'activity' table, this will update the
#' If an `activity` table doesn't exist, it will be created prior to
#' downloading. If there is an existing `activity` table, this will update the
#' records.
#'
#' @examples
Expand All @@ -35,62 +35,25 @@
#' @export

activity <- function(src, resume = FALSE) {
# Update to include activity table
src <- updateMotusDb(src, src)

sql <- safeSQL(src)

# Fetch/resume activity download
batches <- sql("select batchID from batches")[[1]]
p <- sql("select val from meta where key='tagProject'")[[1]] %>%
as.integer()

if(resume) {
# If updating, start with last batch downloaded (a bit of overlap)
last_batch <- sql("select ifnull(max(batchID), 0) from activity")[[1]]
batches <- batches[batches >= last_batch]
} else {
# Otherwise remove all rows and start again
DBI::dbExecute(src$con, "DELETE FROM activity")
getBatches <- function(src) {
dplyr::tbl(src$con, "batches") %>%
dplyr::pull(.data$batchID)
}

if(length(batches) > 0) {
for(i in 1:length(batches)) {
batchID <- batches[i]
# Get first batch
b <- srvActivityForBatches(batchID = batchID)

# If this is the last batch, check if actually new, or just the end of the record
if(resume && i == 1 && identical(last_batch, batches)) {
t <- dplyr::tbl(src$con, "activity") %>%
dplyr::filter(batchID == batches[i]) %>%
dplyr::collect() %>%
as.data.frame()
if(identical(t, b)) break
}

# Only first time
if(i == 1) message(sprintf("Project %5d: %5d batch records to check",
p, length(batches)))

# Progress messages
msg <- sprintf("batchID %8d (#%6d of %6d): ", batchID, i, length(batches))

# Get the rest of the data
while(nrow(b) > 0) {
# Save Previous batch
dbInsertOrReplace(sql$con, "activity", b)
message(msg, sprintf("got %6d activity records", nrow(b)))

# Page forward
ant <- b$ant[nrow(b)]
hourBin <- b$hourBin[nrow(b)]

# Try again
b <- srvActivityForBatches(batchID = batchID,
ant = ant, hourBin = hourBin)
}
}
pageInitial <- function(batchID, projectID) srvActivityForBatches(batchID = batchID)

pageForward <- function(b, batchID, projectID) {
# Page forward
ant <- b$ant[nrow(b)]
hourBin <- b$hourBin[nrow(b)]

# Try again
srvActivityForBatches(batchID = batchID,
ant = ant, hourBin = hourBin)
}
src

pageDataByBatch(src, table = "activity", resume = resume,
getBatches, pageInitial, pageForward)

}
Loading

0 comments on commit c7a014b

Please sign in to comment.