add draft scripts for blog-airtable automation#459
Conversation
✅ Deploy Preview for rladies-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
drmowinckels
left a comment
There was a problem hiding this comment.
This is an excellent starting point!
Let's talk more about the problem with the "Status" column in airtable on Slack, so we can figure out what is needed and how to set it up.
I think a point of improvement would be to refactor it to be a function that takes the data as an argument, which could then gracefully exit (i.e. no quit()). This way you could also make certain common processing steps for each event type be used in both instances. So we could have a file with functions to source for handling the posts, and we could call these to create the files.
What do you think?
| api_key <- Sys.setenv("AIRTABLE_API_KEY") | ||
| base_id <- Sys.getenv("AIRTABLE_BASE_ID") | ||
| table_name <- Sys.getenv("AIRTABLE_TABLE_ID") |
There was a problem hiding this comment.
These are not necessary. The airtabler package will automatically find the AIRTABLE_API_KEY if its set in the environment. And I see no reason to mask the base and table ids, as they should not be accessible without a matching token that has access to them. And I dont think you ever use the table_name in any place?
|
|
||
| if (nrow(events_to_draft) == 0) { | ||
| print("No new event reports to draft") | ||
| quit() |
There was a problem hiding this comment.
This would make the github action fail, I believe.
I think we should look at turning the scripts into functions that can be called and can exit without action when there is nothing to do.
There was a problem hiding this comment.
I added a new script with the functions, but I need help to review them!
cecibaldoni
left a comment
There was a problem hiding this comment.
Hi Mo,
I made some changes, could you have a look when you have time?
drmowinckels
left a comment
There was a problem hiding this comment.
This is looking really good! I think my main issue would be the downloading of images bit, I think it can be a little more streamlined?
| @@ -0,0 +1,103 @@ | |||
| library(airtabler) | |||
| library(tidyverse) | |||
| library(glue) | |||
There was a problem hiding this comment.
you load airtabler and glue in the functions script, so you wouldnt need to load it again here.
|
|
||
| # Create a URL-friendly slug from text | ||
| create_slug <- function(text) { | ||
| text %>% |
There was a problem hiding this comment.
consider switching to base pipe?
|
|
||
| # Download images from URLs and save to folder | ||
| # Returns vector of local filenames | ||
| download_images <- function(image_urls, folder_path) { |
There was a problem hiding this comment.
it returns nothing when there are images to download?
Description
This PR introduces two new R scripts to automate the creation of blog post drafts from Airtable.
scripts/blog-proposal.R: handles general blog post proposals.scripts/blog-events.R: handles event reports and formats them into a standardised post.To do List
blog-proposal.Rblog-events.R