Skip to content

Commit

Permalink
Point to app, not webpage. (#85)
Browse files Browse the repository at this point in the history
* Point to app, not webpage.

* Remove magrittr.
  • Loading branch information
jonthegeek committed Oct 13, 2023
1 parent 5e69e33 commit 2b95cf0
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_shinyapps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
- name: Push to shinyapps
run: |
rsconnect::setAccountInfo(name='r4dscommunity', token=${{secrets.SHINYAPPS_TOKEN}}, secret=${{secrets.SHINYAPPS_SECRET}})
rsconnect::deployApp(appName = 'mentordash')
rsconnect::deployApp(appName = 'mentordash', forceUpdate = TRUE)
shell: Rscript {0}
2 changes: 1 addition & 1 deletion .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: Push to shinyapps
run: |
rsconnect::setAccountInfo(name='r4dscommunity', token=${{secrets.SHINYAPPS_TOKEN}}, secret=${{secrets.SHINYAPPS_SECRET}})
rsconnect::deployApp(appName = 'mentordashtest')
rsconnect::deployApp(appName = 'mentordashtest', forceUpdate = TRUE)
shell: Rscript {0}
31 changes: 13 additions & 18 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
Package: mentordash
Title: Dashboard for the R4DS Online Learning Community
Version: 0.3.9
Version: 0.4.0
Authors@R: c(
person(
'Jon', 'Harmon', email = '[email protected]', role = c('cre', 'aut')
),
person(
'Tan', 'Ho', email = '[email protected]', role = c('ctb')
)
)
Description: This is a golem shiny app for the R4DS Online Learning Community.
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 R4DS Online Learning
Community.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://github.com/r4ds/mentordash
BugReports: https://github.com/r4ds/mentordash/issues
Depends:
R (>= 4.1)
Imports:
config,
dplyr,
DT,
golem (>= 0.2.1),
lubridate,
magrittr,
pkgload,
purrr,
rlang,
Expand All @@ -32,15 +30,12 @@ Imports:
stringr,
tibble,
tidyr (>= 1.0.0)
RoxygenNote: 7.2.1
URL: https://github.com/r4ds/mentordash
BugReports: https://github.com/r4ds/mentordash/issues
Suggests:
testthat
Remotes:
r4ds/scenes,
r4ds/shinyslack,
yonicd/slackteams,
yonicd/slackthreads
Depends:
R (>= 2.10)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(run_app)
importFrom(config,get)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# mentordash 0.4.0

* Links now point to the app, rather than the website, since the website does not always allow linking to specific questions.

# mentordash 0.3.7

* The app has been in a working state for a while now with no news updates! The latest change was to use an HttpOnly cookie, which removes the need for any JavaScript handlers.
Expand Down
73 changes: 27 additions & 46 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@

output$answerable_questions <- DT::renderDataTable({
shiny::req(questions_df())
questions_df() %>%
dplyr::filter(.data$answerable) %>%
dplyr::select(-"answerable", -"speech_balloon") %>%
questions_df() |>
dplyr::filter(.data$answerable) |>
dplyr::select(-"answerable", -"speech_balloon") |>
DT::datatable(
rownames = FALSE,
# filter = 'top',
Expand All @@ -79,9 +79,9 @@
})

output$followup_questions <- DT::renderDataTable({
questions_df() %>%
dplyr::filter(!.data$answerable) %>%
dplyr::select(-"answerable", -"speech_balloon") %>%
questions_df() |>
dplyr::filter(!.data$answerable) |>
dplyr::select(-"answerable", -"speech_balloon") |>
DT::datatable(
rownames = FALSE,
# filter = 'top',
Expand Down Expand Up @@ -165,7 +165,7 @@
)
},
.id = "channel"
) %>%
) |>
# A general unnest_wider was breaking, so let's just get the channels we
# care about.
tidyr::hoist(
Expand All @@ -179,19 +179,19 @@
"reply_users",
"thread_ts",
"text"
) %>%
) |>
dplyr::mutate(
reply_count = tidyr::replace_na(.data$reply_count, 0)
)

mentors <- .get_mentors()

convos_tbl <- convos_tbl %>%
convos_tbl <- convos_tbl |>
# Get rid of channel_join and channel_name.
dplyr::filter(
!(.data$subtype %in% bad_subtypes),
.data$user != "USLACKBOT"
) %>%
) |>
# Only keep "recent" threads.
dplyr::mutate(
latest_activity = as.POSIXct(
Expand All @@ -202,10 +202,10 @@
),
origin = "1970-01-01"
)
) %>%
) |>
dplyr::filter(
.data$latest_activity >= (lubridate::now() - keep_timeframe)
) %>%
) |>
dplyr::mutate(
heavy_check_mark = .has_reaction(
.data$reactions,
Expand All @@ -225,12 +225,12 @@
.data$user,
mentors
)
) %>%
) |>
dplyr::filter(
!.data$heavy_check_mark,
!.data$thread_tag,
!.data$nevermind
) %>%
) |>
dplyr::mutate(
speech_balloon = .has_reaction(
.data$reactions,
Expand All @@ -242,54 +242,35 @@
.data$speech_balloon, .data$user, .data$reply_users,
channel_ids = .data$channel_id, tses = .data$thread_ts
)
) %>%
# Seeing if dumping "waiting for op followup" here speeds things up.
# dplyr::filter(answerable) %>%
) |>
dplyr::mutate(
`web link` = purrr::map2(
link = purrr::map2(
.data$channel_id, .data$ts,
function(chnl, this_ts) {
paste0(
"<a href=\"",
paste(
"https://app.slack.com/client/T6UC1DKJQ",
"https://rfordatascience.slack.com/archives",
chnl,
this_ts,
paste0("p", sub(x = this_ts, "\\.", "")),
sep = "/"
),
"\", target=\"_blank\">Web</a>"
"\", target=\"_blank\">load question</a>"
)
}
),
# `app link` = purrr::map2(
# .data$channel_id, .data$ts,
# function(chnl, this_ts) {
# paste0(
# "<a href=\"",
# paste(
# "https://rfordatascience.slack.com/archives",
# chnl,
# paste0("p", sub(x = this_ts, "\\.", "")),
# sep = "/"
# ),
# "\", target=\"_blank\">App</a>"
# )
# }
# ),
excerpt = stringr::str_trunc(text, 100),
# links = paste(`web link`, `app link`, sep = " | "),
latest_activity = format(latest_activity, "%Y-%m-%d %H:%M:%S")
) %>%
) |>
dplyr::select(
.data$channel,
.data$excerpt,
.data$reply_count,
.data$speech_balloon,
.data$answerable,
.data$`web link`,
# .data$links,
.data$link,
.data$latest_activity
) %>%
) |>
dplyr::arrange(.data$latest_activity)

return(convos_tbl)
Expand Down Expand Up @@ -380,11 +361,11 @@
),
.f = function(ts, channel_id, user, reply_users) {
if (user %in% reply_users) {
last_reply_user <- slackthreads::replies(ts, channel_id) %>%
tibble::enframe() %>%
tidyr::hoist(.data$value, "ts", "user") %>%
dplyr::arrange(dplyr::desc(ts)) %>%
dplyr::slice(1) %>%
last_reply_user <- slackthreads::replies(ts, channel_id) |>
tibble::enframe() |>
tidyr::hoist(.data$value, "ts", "user") |>
dplyr::arrange(dplyr::desc(ts)) |>
dplyr::slice(1) |>
dplyr::pull(user)
return(last_reply_user == user)
} else {
Expand Down
11 changes: 0 additions & 11 deletions R/utils-pipe.R

This file was deleted.

2 changes: 1 addition & 1 deletion app.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pkgload::load_all(
quiet = TRUE
)

options( "golem.app.prod" = TRUE)
options("golem.app.prod" = TRUE)
run_app() # add parameters here (if any)
7 changes: 6 additions & 1 deletion man/dot-has_reaction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/dot-tidy_convos.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions man/pipe.Rd

This file was deleted.

0 comments on commit 2b95cf0

Please sign in to comment.