Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
0509e610
Commit
0509e610
authored
8 years ago
by
Atte Keinänen
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup for missing #metabase_files error
parent
2ceb2078
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/integrations/slack.clj
+16
-8
16 additions, 8 deletions
src/metabase/integrations/slack.clj
src/metabase/pulse.clj
+1
-1
1 addition, 1 deletion
src/metabase/pulse.clj
with
17 additions
and
9 deletions
src/metabase/integrations/slack.clj
+
16
−
8
View file @
0509e610
...
...
@@ -45,18 +45,26 @@
"Calls Slack api `users.list` function and returns the list of available users."
(
comp
:members
(
partial
GET
:users.list
)))
(
def
^
:private
^
:const
^
String
channel-missing-msg
(
str
"Slack channel named `metabase_files` is missing! Please create the channel in order to complete "
"the Slack integration. The channel is used for storing graphs that are included in pulses and "
"MetaBot answers."
))
(
defn-
maybe-get-files-channel
"Return the `metabase_files channel (as a map) if it exists."
[]
(
some
(
fn
[
channel
]
(
when
(
=
(
:name
channel
)
files-channel-name
)
channel
))
(
channels-list
:exclude_archived
0
)))
(
defn
files-channel
"Calls Slack api `channels.info` to check whether a channel named #metabase_files exists. If it doesn't,
throws an error that advices an admin to create it."
[]
(
or
(
some
(
fn
[
channel
]
(
when
(
=
(
:name
channel
)
files-channel-name
)
channel
))
(
channels-list
:exclude_archived
0
))
(
let
[
channel-missing-msg
(
str
"Slack channel named `metabase_files` is missing! Please create the channel in order to complete"
"the Slack integration. The channel is used for storing graphs that are included in pulses and "
"Metabot anwers."
)]
(
log/error
(
u/format-color
'red
channel-missing-msg
))
(
throw
(
Exception.
channel-missing-msg
)))))
(
or
(
maybe-get-files-channel
)
(
do
(
log/error
(
u/format-color
'red
channel-missing-msg
))
(
throw
(
ex-info
channel-missing-msg
{
:status-code
400
})))))
(
defn
upload-file!
"Calls Slack api `files.upload` function and returns the body of the uploaded file."
...
...
This diff is collapsed.
Click to expand it.
src/metabase/pulse.clj
+
1
−
1
View file @
0509e610
...
...
@@ -46,7 +46,7 @@
(
defn
create-and-upload-slack-attachments!
"Create an attachment in Slack for a given Card by rendering its result into an image and uploading it."
[
card-results
]
(
when-
let
[{
channel-id
:id
}
(
slack/files-channel
)]
(
let
[{
channel-id
:id
}
(
slack/files-channel
)]
(
doall
(
for
[{{
card-id
:id,
card-name
:name,
:as
card
}
:card,
result
:result
}
card-results
]
(
let
[
image-byte-array
(
render/render-pulse-card-to-png
card
result
)
slack-file-url
(
slack/upload-file!
image-byte-array
"image.png"
channel-id
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment