Skip to content

Commit 074e4e7

Browse files
authored
Merge pull request #95 from ropensci-review-tools/weeks
fix indexing of annual weeks in commit-freq metric
2 parents e049e23 + 4f9834a commit 074e4e7

4 files changed

+13
-6
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: repometrics
22
Title: Metrics for Your Code Repository
3-
Version: 0.1.5.024
3+
Version: 0.1.5.026
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/cm-metric-cran-downloads.R

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ cran_downloads_internal <- function (pkg_name = NULL,
4545
req_url <- paste0 (daily_url, interval, "/", pkg_name)
4646

4747
req <- httr2::request (req_url)
48-
resp <- httr2::req_perform (req)
48+
resp <- tryCatch (
49+
httr2::req_perform (req),
50+
error = function (e) NULL
51+
)
52+
if (is.null (resp)) {
53+
return (data.frame (date = as.Date (character (0L)), downloads = integer (0L)))
54+
}
4955
httr2::resp_check_status (resp)
5056

5157
body <- httr2::resp_body_json (resp)

R/cm-metrics-commits.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ cm_metric_commit_freq <- function (path, end_date = Sys.Date ()) {
3131

3232
week <- round (as.numeric (log$week), digits = 2)
3333
index <- seq (min (week), max (week), by = 0.01)
34-
index_years <- index - floor (index)
35-
index_in_52 <- which (index_years >= 0 & index_years <= 0.52)
36-
index <- sprintf ("%.2f", index [index_in_52])
34+
index_weeks <- round (index - floor (index), digits = 2)
35+
# This is 53, because end of year is start of 53rd week:
36+
index_in_53 <- which (index_weeks >= 0 & index_weeks <= 0.53)
37+
index <- sprintf ("%.2f", index [index_in_53])
3738

3839
commits <- rep (0, length (index))
3940
index_log <- match (log$week, index)

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
99
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.5.024",
11+
"version": "0.1.5.026",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

0 commit comments

Comments
 (0)