---
title: "CRAN incoming dashboard"
date: "`r format(Sys.time(), '%F %R UTC%z')`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{CRAN incoming dashboard}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE,
  echo = FALSE
)
```

The data in this table stems from our querying https://cran.r-project.org/incoming/.
We update it every hour. [See below](#cran-review-workflow) for a description of each 
folder meaning.

<img src="https://github.com/r-hub/cransays/workflows/Render-dashboard/badge.svg" aria-hidden="true">

# Dashboard

```{r get-data}
library(dplyr)

standard_folders <- c(
  "pretest", "inspect", "recheck", "pending", "publish", "newbies", "waiting"
)

cran_raw <- cransays::take_snapshot()

cran_incoming <- cran_raw |> 
  arrange(subfolder, howlongago) |>
  filter(subfolder != "archive") |>
  mutate(
    folder = ifelse(subfolder %in% standard_folders, subfolder, "human"),
    subfolder = ifelse(subfolder %in% standard_folders, NA, subfolder)
  )

cran_incoming |>
  select(package, version, snapshot_time, folder, subfolder, submission_time) |>
  arrange(package, version) |>
  write.csv(
    paste0("cran-incoming-v5-", format(Sys.time(), "%Y%m%dT%H%M%S"), ".csv"),
    row.names = FALSE,
    quote = FALSE
  )
```

```{r}
library(reactable)

colours <- c(
  "pretest" = "#F8F3BA",
  "inspect" = "#F8F3BA",
  "human"   = "#F1D9A1",
  "recheck" = "#E5CADB",
  "publish" = "#A5D6C8"
)

cran_incoming |>
  dplyr::select(package, version, submission_time, folder, subfolder) |>
  reactable(
    columns = list(
      folder = colDef(style = function(value) {
        val <- as.character(value)
        if (val %in% names(colours)) {
          list(background = colours[[val]])
        } else {
          list()
        }
      }),
      submission_time = colDef(cell = function(value, index) {
        prettyunits::time_ago(value)
      })
    ),
    defaultSorted = list("submission_time" = "desc"),
    filterable = TRUE,
    defaultPageSize = 50
  )
```


# CRAN review workflow

Your package will be stored in a different folder depending on its current state
in the review process. The exact meaning of each folder is detailed in articles from 
the R Journal in [2018](https://journal.r-project.org/archive/2018-1/cran.pdf) and [2019](https://journal.r-project.org/archive/2019-1/cran.pdf), and updated by a [2019 mailing list post](https://stat.ethz.ch/pipermail/r-package-devel/2019q1/003631.html) (and [confirmed in 2022](https://stat.ethz.ch/pipermail/r-package-devel/2022q2/008084.html)):

- **inspect**: your package is awaiting manual inspection by the CRAN team, probably because automated tests found a problem that is likely to be a false positive
- **newbies**: a specific queue for the manual inspection of first-time CRAN submissions.
- **pending**: a CRAN team member has to do a closer inspection and needs more time.
- **human**: your package has been assigned to a specific CRAN member (with initials as indicated by `subfolder`) for further inspection.
- **waiting**: the CRAN team is waiting for an answer from you, e.g. because issues are present that CRAN cannot automatically check for, such as maintainer changes (check your e-mail ...)
- **pretest**: the CRAN maintainers restarted automated tests on your package to
see whether an issue has been fixed by your action or is still present.
- **archive**: your package has been rejected from CRAN because it did not pass checks cleanly and the problems were not likely to be false positives.
- **recheck**: your package has passed basic checks. Because other CRAN packages depend on yours ("reverse dependencies"), a reverse-dependency-checking step is underway to see if your update has broken anything downstream.
- **publish**: you're all set! Your package has passed the review process and 
will soon be available on CRAN.

This information is (approximately) summarised in the following diagram by Hadley Wickham,
available in the [cran-stages Github](https://github.com/edgararuiz/cran-stages)
repository:

```{r, out.width="50%", fig.align='center'}
knitr::include_graphics("cran-diagram.png")
```
