Skip to content

Commit

Permalink
Merge pull request #38 from CorrelAid/metabase-sample-database-adjust…
Browse files Browse the repository at this point in the history
…ments

extended reference class rmd, deleted database rmd and adjusted renv …
  • Loading branch information
KonradUdoHannes committed Mar 17, 2023
2 parents b7c6586 + 5f779ba commit 35a8a86
Show file tree
Hide file tree
Showing 8 changed files with 772 additions and 1,147 deletions.
14 changes: 11 additions & 3 deletions R/ref-class-client.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ MetabaseClient$methods(
)

MetabaseClient$methods(
create_collection = function(collection_name, parent_collection_id) {
create_collection = function(collection_name, parent_collection_id = NULL) {
params <- list(
"name" = collection_name,
"parent_id" = parent_collection_id,
"parent_id" = as.integer(parent_collection_id),
"color" = "#509EE3"
)
authenticated_post(endpoint = "/collection/", payload = params)
Expand Down Expand Up @@ -168,7 +168,7 @@ MetabaseClient$methods(
create_card = function(name, collection_id, query) {
payload <- list(
visualization_settings = setNames(list(), character(0)),
collection_id = collection_id,
collection_id = as.integer(collection_id),
name = name,
dataset_query = query,
display = "table"
Expand All @@ -177,3 +177,11 @@ MetabaseClient$methods(
card_response$id
}
)

MetabaseClient$methods(
run_card = function(card_id) {
uri <- paste0("/card/", card_id, "/query/json")
card_response <- .self$authenticated_post(uri)
dplyr::bind_rows(card_response)
}
)
1 change: 1 addition & 0 deletions man/MetabaseClient-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ showClass("MetabaseClient")
\section{Methods}{
\describe{
\item{\code{create_card(name, collection_id, query)}:}{ Create a card of name "name" as part of collection with "collection_id" using query "query". }
\item{\code{run_card(card_id)}:}{Executes (runs) the query associated with the card of the given id. The result is returned as a tiblle. }
\item{\code{get_tables()}:}{ Get tibble containing abailable tables for queries. }
\item{\code{create_collection(collection_name, parent_collection_id)}:}{ Create a collection.}
\item{\code{get_card(card_id)}:}{ Get a json representation of a card. }
Expand Down

0 comments on commit 35a8a86

Please sign in to comment.