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
dd30e8da
Commit
dd30e8da
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
finish off the handling of dashboard events which feed into the activity feed.
parent
d5107702
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/dash.clj
+6
-4
6 additions, 4 deletions
src/metabase/api/dash.clj
src/metabase/models/activity.clj
+29
-15
29 additions, 15 deletions
src/metabase/models/activity.clj
with
35 additions
and
19 deletions
src/metabase/api/dash.clj
+
6
−
4
View file @
dd30e8da
...
...
@@ -74,17 +74,19 @@
(
write-check
Dashboard
id
)
(
check-400
(
exists?
Card
:id
cardId
))
(
let
[
result
(
ins
DashboardCard
:card_id
cardId
:dashboard_id
id
)]
(
events/publish-event
:dashboard-add-cards
{
:id
id
:actor_id
*current-user-id*
:dashcard
result
})
(
events/publish-event
:dashboard-add-cards
{
:id
id
:actor_id
*current-user-id*
:dashcard
s
[
result
]
})
(
push-revision
:entity
Dashboard,
:object
(
Dashboard
id
))
result
))
(
defendpoint
DELETE
"/:id/cards"
"Remove a `Card` from a `Dashboard`."
"Remove a `
Dashboard
Card` from a `Dashboard`."
[
id
dashcardId
]
{
dashcardId
[
Required
String->Integer
]}
(
write-check
Dashboard
id
)
(
let
[
result
(
del
DashboardCard
:id
dashcardId
:dashboard_id
id
)]
(
events/publish-event
:dashboard-remove-cards
{
:id
id
:actor_id
*current-user-id*
:dashcard
dashcardId
})
;; TODO - it would be nicer to do this if `del` returned the object that was deleted instead of an api response
(
let
[
dashcard
(
sel
:one
DashboardCard
:id
dashcardId
)
result
(
del
DashboardCard
:id
dashcardId
:dashboard_id
id
)]
(
events/publish-event
:dashboard-remove-cards
{
:id
id
:actor_id
*current-user-id*
:dashcards
[
dashcard
]})
(
push-revision
:entity
Dashboard,
:object
(
Dashboard
id
))
result
))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/models/activity.clj
+
29
−
15
View file @
dd30e8da
...
...
@@ -5,7 +5,8 @@
[
metabase.api.common
:refer
[
*current-user-id*
]]
[
metabase.db
:refer
:all
]
[
metabase.events
:as
events
]
(
metabase.models
[
interface
:refer
:all
]
(
metabase.models
[
dashboard
:refer
[
Dashboard
]]
[
interface
:refer
:all
]
[
session
:refer
[
Session
]]
[
user
:refer
[
User
]])
[
metabase.util
:as
u
]))
...
...
@@ -107,26 +108,40 @@
(
defn-
record-activity
"Simple base function for recording activity using defaults.
Allows caller to specify a custom serialization function to apply to `object` to generate the activity `:details`."
[
topic
object
object-serialize-fn
]
(
ins
Activity
:topic
topic
:model
(
topic->model
topic
)
:model_id
(
object->model-id
topic
object
)
:custom_id
(
:custom_id
object
)
:user_id
(
object->user-id
object
)
:details
(
if
(
fn?
object-serialize-fn
)
(
object-serialize-fn
object
)
object
)))
([
topic
object
serialize-fn
]
(
ins
Activity
:topic
topic
:model
(
topic->model
topic
)
:model_id
(
object->model-id
topic
object
)
:custom_id
(
:custom_id
object
)
:user_id
(
object->user-id
object
)
:details
(
if
(
fn?
serialize-fn
)
(
serialize-fn
object
)
object
)))
([
topic
object
]
(
record-activity
topic
object
nil
)))
(
defn-
process-card-activity
""
[])
(
defn-
process-dashboard-activity
[
topic
object
]
(
let
[
create-delete-details
#
(
select-keys
%
[
:description
:name
:public_perms
])]
(
let
[
create-delete-details
#
(
select-keys
%
[
:description
:name
:public_perms
])
add-remove-card-details
(
fn
[{
:keys
[
dashcards
]
:as
obj
}]
;; we expect that the object has just a dashboard :id at the top level
;; plus a `:dashcards` attribute which is a vector of the cards added/removed
(
->
(
sel
:one
Dashboard
:id
(
:id
obj
))
(
select-keys
[
:description
:name
:public_perms
])
(
assoc
:dashcards
(
for
[{
:keys
[
id
card_id
card
]}
dashcards
]
(
->
@
card
(
select-keys
[
:name
:description
:public_perms
])
(
assoc
:id
id
)
(
assoc
:card_id
card_id
))))))]
(
case
topic
:dashboard-create
(
record-activity
topic
object
create-delete-details
)
:dashboard-delete
(
record-activity
topic
object
create-delete-details
))))
:dashboard-create
(
record-activity
topic
object
create-delete-details
)
:dashboard-delete
(
record-activity
topic
object
create-delete-details
)
:dashboard-add-cards
(
record-activity
topic
object
add-remove-card-details
)
:dashboard-remove-cards
(
record-activity
topic
object
add-remove-card-details
))))
(
defn-
process-database-activity
[
topic
object
]
(
case
topic
...
...
@@ -156,7 +171,6 @@
(
when-let
[{
topic
:topic
object
:item
}
activity-event
]
(
log/info
"Activity:"
topic
)
(
clojure.pprint/pprint
object
)
;; TODO - we need a protocol on our Entities for providing relevant details
(
case
(
topic->model
topic
)
"card"
(
process-card-activity
)
"dashboard"
(
process-dashboard-activity
topic
object
)
...
...
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