Skip to content

Commit ee6c5f8

Browse files
sbfnksbfnk-bot
andcommitted
Add "processed" label to prevent duplicate publication issues
- fetch-new-papers now checks both open issues AND closed issues with "processed" label for existing DOIs - update-bibtex adds "processed" label when closing issues - Papers you've reviewed (whether added or not) won't reappear - Open issues can persist indefinitely without creating duplicates Co-Authored-By: sbfnk-bot <sbfnk-bot@users.noreply.github.com>
1 parent cda99fb commit ee6c5f8

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

snippets/post_publications.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@ source("_automation/get_new_papers.R")
44
month_1st <- format(lubridate::floor_date(lubridate::today() - 1, "month"))
55
new_papers <- get_new_papers_team(from_date = month_1st)
66

7+
# Get DOIs from open OR processed publications issues to avoid duplicates
8+
# "processed" label marks issues that have been reviewed (even if no papers added)
9+
open_issues <- gh::gh(
10+
"/repos/{gh_repo}/issues",
11+
gh_repo = gh_repository,
12+
state = "all",
13+
labels = "publications",
14+
per_page = 100
15+
) |>
16+
purrr::keep(~ .x$state == "open" || "processed" %in% purrr::map_chr(.x$labels, "name"))
17+
18+
pending_dois <- character(0)
19+
if (length(open_issues) > 0) {
20+
# Extract DOIs from issue bodies using regex
21+
pending_dois <- open_issues |>
22+
purrr::map_chr("body", .default = "") |>
23+
purrr::map(~ regmatches(.x, gregexpr("doi\\s*=\\s*\\{([^}]+)\\}", .x, ignore.case = TRUE))) |>
24+
purrr::map(~ gsub("doi\\s*=\\s*\\{|\\}", "", .x, ignore.case = TRUE)) |>
25+
unlist() |>
26+
unique()
27+
}
28+
29+
# Filter out papers already in open issues
30+
if (nrow(new_papers) > 0 && length(pending_dois) > 0) {
31+
new_papers <- new_papers |>
32+
dplyr::filter(!(doi %in% pending_dois))
33+
}
34+
735
if (nrow(new_papers) > 0) {
836
bibentries_new <- create_bibentries(new_papers)
937
saveRDS(bibentries_new, paste0("bibentries_previous_month.rds"))

snippets/update_publications.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ if (!any(selected)) {
6767
"PATCH /repos/{gh_repo}/issues/{issue_number}",
6868
gh_repo = gh_repository,
6969
issue_number = issue_number,
70-
state = "closed"
70+
state = "closed",
71+
labels = list("publications", "processed")
7172
)
7273
quit(save = "no")
7374
}
@@ -120,10 +121,11 @@ df <- df |>
120121

121122
bib2df::df2bib(df, file = "_data/papers.bib")
122123

123-
# Close the issue after processing
124+
# Close the issue and add "processed" label
124125
gh::gh(
125126
"PATCH /repos/{gh_repo}/issues/{issue_number}",
126127
gh_repo = gh_repository,
127128
issue_number = issue_number,
128-
state = "closed"
129+
state = "closed",
130+
labels = list("publications", "processed")
129131
)

0 commit comments

Comments
 (0)