From 4ce67c1393243bc5044f5926b6168d10fc2c935f Mon Sep 17 00:00:00 2001 From: mpadge Date: Wed, 20 Mar 2024 12:20:29 +0100 Subject: [PATCH] add 'review_history' fn for #7 --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/reviews.R | 11 +++++++---- codemeta.json | 2 +- man/review_history.Rd | 20 ++++++++++++++++++++ 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 man/review_history.Rd diff --git a/DESCRIPTION b/DESCRIPTION index f8d5ee0..2f187ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.0.8.004 +Version: 0.0.9 Authors@R: person(given = "First", family = "Last", diff --git a/NAMESPACE b/NAMESPACE index 80a7e1c..76b14ff 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,4 +3,5 @@ export(add_editor_airtable_data) export(editor_status) export(editor_vacation_status) +export(review_history) export(review_status) diff --git a/R/reviews.R b/R/reviews.R index a892ac8..cf5a19d 100644 --- a/R/reviews.R +++ b/R/reviews.R @@ -428,8 +428,7 @@ extract_comment_info <- function (dat) { )) } -#' Apply the 'gh_issues_qry_dates_states' query to extract data from GitHub -#' GraphQL API, and post-process into a `data.frame`. +#' Generate historical data on software reviews. #' #' This is a reduced version of the `reviews_gh_data()` function, which returns #' data only on dates of issue opening and closing, to be used to generate @@ -438,8 +437,8 @@ extract_comment_info <- function (dat) { #' @param quiet If `FALSE`, display progress information on screen. #' @return (Invisibly) A `data.frame` with one row per issue and some key #' statistics. -#' @noRd -reviews_gh_data_dates_states <- function (open_only = TRUE, quiet = FALSE) { +#' @export +review_history <- function (quiet = FALSE) { has_next_page <- TRUE end_cursor <- NULL @@ -516,6 +515,7 @@ reviews_gh_data_dates_states <- function (open_only = TRUE, quiet = FALSE) { closed_at <- closed_at [pkg_index] submission_type <- submission_type [pkg_index] state <- state [pkg_index] + labels <- labels [pkg_index] # labels are then only used to identify stats submissions: stats <- vapply (labels, function (i) "stats" %in% i, logical (1L)) @@ -528,5 +528,8 @@ reviews_gh_data_dates_states <- function (open_only = TRUE, quiet = FALSE) { closed_at = lubridate::date (lubridate::ymd_hms (closed_at)) ) |> dplyr::arrange (number) + dtime <- lubridate::interval (res$opened_at, res$closed_at) + res$duration_days <- as.numeric (dtime) / (24 * 3600) + return (res) } diff --git a/codemeta.json b/codemeta.json index f03aa34..625fe0b 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "name": "dashboard: What the Package Does (One Line, Title Case)", "codeRepository": "https://github.com/ropensci-review-tools/dashboard", "license": "https://spdx.org/licenses/MIT", - "version": "0.0.8.004", + "version": "0.0.9", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/man/review_history.Rd b/man/review_history.Rd new file mode 100644 index 0000000..6f96632 --- /dev/null +++ b/man/review_history.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reviews.R +\name{review_history} +\alias{review_history} +\title{Generate historical data on software reviews.} +\usage{ +review_history(quiet = FALSE) +} +\arguments{ +\item{quiet}{If `FALSE`, display progress information on screen.} +} +\value{ +(Invisibly) A `data.frame` with one row per issue and some key +statistics. +} +\description{ +This is a reduced version of the `reviews_gh_data()` function, which returns +data only on dates of issue opening and closing, to be used to generate +historical patterns. +}