Skip to content

Commit

Permalink
Fix week 1 process. (#63)
Browse files Browse the repository at this point in the history
Need to confirm that the round --> floor doesn't break things later!
  • Loading branch information
jonthegeek authored Jan 6, 2025
1 parent 68efb55 commit 0577bfe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion helpers-generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ next_week_num <- function() {
jan_1st <- paste0(year, "0101")
jan_1st <- lubridate::ymd(jan_1st)
week_num <- as.numeric((week_date - jan_1st))/7 + 1
return(round(week_num))
return(floor(week_num))
}

next_year <- function() {
Expand Down
2 changes: 1 addition & 1 deletion runner-bsky.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bsky_msg_start <- stringr::str_replace(

bsky_msg <- paste(bsky_msg_start, status_msg_end, sep = "\n")

if (nchar(article_msg) + nchar(bsky_msg) < 300) {
if (length(article_msg) && nchar(article_msg) + nchar(bsky_msg) < 300) {
bsky_msg_start <- paste(bsky_msg_start, article_msg, sep = "\n")
bsky_msg <- paste(bsky_msg_start, status_msg_end, sep = "\n")
}
Expand Down
4 changes: 4 additions & 0 deletions runner-shared.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ call_to_action <- paste0(
"Submit a dataset! https://github.com/rfordatascience/tidytuesday/blob/main/.github/CONTRIBUTING.md"
)

metadata <- NULL
article_msg <- NULL

# Week 1 is "bring your own data", let's deal with that specifically.
if (week_num == 1) {
status_msg_start <- glue::glue(
Expand All @@ -20,6 +23,7 @@ if (week_num == 1) {
"{emoji::emoji('question')} Whatever else you want to use!",
.sep = "\n"
)
status_msg_start_not_bsky <- status_msg_start
status_msg_end <- "\n#r4ds #tidyverse #DataViz"
img_paths <- NULL
alt_text <- NULL
Expand Down
2 changes: 1 addition & 1 deletion runner-toot.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source("runner-shared.R", local = TRUE)
# Toot.
source("helpers-mastodon.R", local = TRUE)

if (length(metadata$credit$mastodon)) {
if (length(metadata) && length(metadata$credit$mastodon)) {
credit <- glue::glue(
"Curator: {metadata$credit$mastodon}"
)
Expand Down
1 change: 1 addition & 0 deletions ttpost.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 9d1827f2-5ea8-4029-bfc5-186a1a1740eb

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down

0 comments on commit 0577bfe

Please sign in to comment.