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
3770ac9c
Commit
3770ac9c
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
cleanup a few bits and pieces based on feedback on the PR.
parent
3b8da0cc
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/pulse.clj
+1
-1
1 addition, 1 deletion
src/metabase/api/pulse.clj
src/metabase/models/pulse.clj
+10
-11
10 additions, 11 deletions
src/metabase/models/pulse.clj
with
11 additions
and
12 deletions
src/metabase/api/pulse.clj
+
1
−
1
View file @
3770ac9c
...
...
@@ -45,7 +45,7 @@
(
check-404
(
db/exists?
Pulse
:id
id
))
(
pulse/update-pulse
{
:id
id
:name
name
:cards
(
filter
identity
(
into
[]
(
map
:id
cards
))
)
:cards
(
filter
identity
(
map
:id
cards
))
:channels
channels
})
(
pulse/retrieve-pulse
id
))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/models/pulse.clj
+
10
−
11
View file @
3770ac9c
...
...
@@ -33,14 +33,13 @@
(
post-select
[
_
{
:keys
[
id
creator_id
]
:as
pulse
}]
(
map->PulseInstance
(
u/assoc*
pulse
:cards
(
delay
(
k/select
Card
(
k/join
PulseCard
(
=
:pulse_card.card_id
:id
))
(
k/fields
:id
:name
:description
:display
)
(
k/where
{
:pulse_card.pulse_id
id
})
(
k/order
:pulse_card.position
:asc
)))
:channels
(
delay
(
db/sel
:many
PulseChannel
(
k/where
{
:pulse_id
id
})))
:creator
(
delay
(
when
creator_id
(
db/sel
:one
User
:id
creator_id
))))))
(
assoc
pulse
:cards
(
delay
(
k/select
Card
(
k/join
PulseCard
(
=
:pulse_card.card_id
:id
))
(
k/fields
:id
:name
:description
:display
)
(
k/where
{
:pulse_card.pulse_id
id
})
(
k/order
:pulse_card.position
:asc
)))
:channels
(
delay
(
db/sel
:many
PulseChannel
(
k/where
{
:pulse_id
id
})))
:creator
(
delay
(
when
creator_id
(
db/sel
:one
User
:id
creator_id
))))))
(
pre-cascade-delete
[
_
{
:keys
[
id
]}]
(
db/cascade-delete
PulseCard
:pulse_id
id
)
...
...
@@ -64,7 +63,7 @@
(
coll?
card-ids
)
(
every?
integer?
card-ids
)]}
;; first off, just delete any cards associated with this pulse (we add them again below)
(
k/
delete
PulseCard
(
k/where
{
:pulse_id
id
})
)
(
db/cascade-
delete
PulseCard
:pulse_id
id
)
;; now just insert all of the cards that were given to us
(
let
[
cards
(
map-indexed
(
fn
[
idx
itm
]
{
:pulse_id
id
:card_id
itm
:position
idx
})
card-ids
)]
(
k/insert
PulseCard
(
k/values
cards
))))
...
...
@@ -97,8 +96,8 @@
{
:pre
[(
integer?
id
)
(
coll?
channels
)
(
every?
map?
channels
)]}
(
let
[
new-channels
(
group-by
#
(
keyword
(
:channel_type
%
)
)
channels
)
old-channels
(
group-by
#
(
keyword
(
:channel_type
%
)
)
(
db/sel
:many
PulseChannel
:pulse_id
id
))
(
let
[
new-channels
(
group-by
(
comp
keyword
:channel_type
)
channels
)
old-channels
(
group-by
(
comp
keyword
:channel_type
)
(
db/sel
:many
PulseChannel
:pulse_id
id
))
handle-channel
#
(
create-update-delete-channel
id
(
first
(
get
new-channels
%
))
(
first
(
get
old-channels
%
)))]
(
assert
(
=
0
(
count
(
get
new-channels
nil
)))
"Cannot have channels without a :channel_type attribute"
)
(
dorun
(
map
handle-channel
(
vec
(
keys
pulse-channel/channel-types
))))))
...
...
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