Skip to content

Commit

Permalink
Update for shinyslack 0.0.0.9010 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthegeek authored Apr 9, 2024
1 parent 2bc2b6b commit 12b4ded
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Authors@R: c(
person("Jon", "Harmon", , "[email protected]", role = c("cre", "aut")),
person("Tan", "Ho", , "[email protected]", role = "ctb")
)
Description: This is a golem shiny app for the Data Science Learning Community.
Description: This is a golem shiny app for the Data Science Learning
Community.
License: MIT + file LICENSE
URL: https://github.com/r4ds/mentordash
BugReports: https://github.com/r4ds/mentordash/issues
Expand All @@ -23,7 +24,8 @@ Imports:
scenes (>= 0.0.0.9003),
shiny (>= 1.5.0),
shinydashboard,
shinyslack (>= 0.0.0.9006),
shinyslack (>= 0.0.0.9010),
slackcalls,
slackteams (>= 0.4.3),
slackthreads (>= 0.1.0),
stringr,
Expand All @@ -33,6 +35,7 @@ Suggests:
testthat
Remotes:
r4ds/shinyslack,
yonicd/slackcalls,
yonicd/slackteams,
yonicd/slackthreads
Encoding: UTF-8
Expand Down
31 changes: 23 additions & 8 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@
})
}

.get_question_channels <- function() {
channels <- slackteams::get_conversations_list(type = "public_channel")
.get_question_channels <- function(session = shiny::getDefaultReactiveDomain(),
slack_api_key = session$userData$shinyslack_api_key) {
channels <- slackteams::get_conversations_list(
type = "public_channel",
token = slack_api_key
)
question_channels_df <- dplyr::filter(
channels, stringr::str_starts(.data$name, "help-")
)
Expand All @@ -104,10 +108,12 @@
return(question_channels)
}

.get_mentors <- function() {
.get_mentors <- function(session = shiny::getDefaultReactiveDomain(),
slack_api_key = session$userData$shinyslack_api_key) {
mentors <- slackcalls::post_slack(
"conversations.members",
channel = "GAJ8D7YKA"
channel = "GAJ8D7YKA",
token = slack_api_key
)

if (mentors$ok && "members" %in% names(mentors)) {
Expand All @@ -123,15 +129,18 @@
#'
#' @return A tidy tibble of question information.
#' @keywords internal
.get_questions <- function(question_channels) {
.get_questions <- function(question_channels,
session = shiny::getDefaultReactiveDomain(),
slack_api_key = session$userData$shinyslack_api_key) {
## Read in Conversations ----
total_results <- 100L

convos <- purrr::map(
question_channels,
slackthreads::conversations,
max_results = total_results,
limit = min(total_results, 1000L)
limit = min(total_results, 1000L),
token = slack_api_key
)

## Response to Tibble ----
Expand Down Expand Up @@ -333,7 +342,9 @@
users,
reply_userses,
channel_ids,
tses) {
tses,
session = shiny::getDefaultReactiveDomain(),
slack_api_key = session$userData$shinyslack_api_key) {
# We need to return a logical vector indicating whether this question is
# "answerable", meaning the thread hasn't been tagged as needing more info OR
# there isn't a reply OR the latest reply was by the user. To determine the
Expand Down Expand Up @@ -361,7 +372,11 @@
),
.f = function(ts, channel_id, user, reply_users) {
if (user %in% reply_users) {
last_reply_user <- slackthreads::replies(ts, channel_id) |>
last_reply_user <- slackthreads::replies(
ts,
channel_id,
token = slack_api_key
) |>
tibble::enframe() |>
tidyr::hoist(.data$value, "ts", "user") |>
dplyr::arrange(dplyr::desc(ts)) |>
Expand Down
10 changes: 9 additions & 1 deletion app.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@ pkgload::load_all(
quiet = TRUE
)

options("golem.app.prod" = TRUE)
# options("golem.app.prod" = TRUE)
options("golem.app.prod" = FALSE)
run_app() # add parameters here (if any)

# Debug just the UI without login:

# shiny::shinyApp(
# ui = .app_ui,
# server = .app_server
# )

0 comments on commit 12b4ded

Please sign in to comment.