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
b4850a3c
Commit
b4850a3c
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
more tweaks based on PR comments.
parent
dcb9f937
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/models/pulse.clj
+4
-4
4 additions, 4 deletions
src/metabase/models/pulse.clj
src/metabase/models/pulse_channel.clj
+12
-14
12 additions, 14 deletions
src/metabase/models/pulse_channel.clj
with
16 additions
and
18 deletions
src/metabase/models/pulse.clj
+
4
−
4
View file @
b4850a3c
...
...
@@ -48,7 +48,7 @@
(
extend-ICanReadWrite
PulseEntity
:read
:public-perms,
:write
:public-perms
)
;; ##
Helper
Functions
;; ##
Persistence
Functions
(
defn-
update-pulse-cards
"Update the `PulseCards` for a given PULSE.
...
...
@@ -60,7 +60,7 @@
{
:arglists
'
([
pulse
card-ids
])}
[{
:keys
[
id
]}
card-ids
]
{
:pre
[(
integer?
id
)
(
col
l?
card-ids
)
(
sequentia
l?
card-ids
)
(
every?
integer?
card-ids
)]}
;; first off, just delete any cards associated with this pulse (we add them again below)
(
db/cascade-delete
PulseCard
:pulse_id
id
)
...
...
@@ -122,7 +122,7 @@
[{
:keys
[
id
name
cards
channels
]
:as
pulse
}]
{
:pre
[(
integer?
id
)
(
string?
name
)
(
col
l?
cards
)
(
sequentia
l?
cards
)
(
>
(
count
cards
)
0
)
(
every?
integer?
cards
)
(
coll?
channels
)
...
...
@@ -142,7 +142,7 @@
[
name
creator-id
cards
channels
]
{
:pre
[(
string?
name
)
(
integer?
creator-id
)
(
col
l?
cards
)
(
sequentia
l?
cards
)
(
>
(
count
cards
)
0
)
(
every?
integer?
cards
)
(
coll?
channels
)
...
...
This diff is collapsed.
Click to expand it.
src/metabase/models/pulse_channel.clj
+
12
−
14
View file @
b4850a3c
...
...
@@ -11,7 +11,7 @@
;; ## Static Definitions
(
def
channel-types
(
def
^
:const
channel-types
"Map which contains the definitions for each type of pulse channel we allow. Each key is a channel type with a map
which contains any other relevant information for defining the channel. E.g.
...
...
@@ -25,7 +25,7 @@
[
channel-type
]
(
contains?
(
set
(
keys
channel-types
))
(
keyword
channel-type
)))
(
def
schedule-types
(
def
^
:const
schedule-types
"Map which contains the definitions for each type of pulse schedule type we allow. Each key is a schedule-type with
a map which contains any other relevant information related to the defined schedule-type. E.g.
...
...
@@ -46,7 +46,7 @@
(
boolean
(
:recipients?
(
get
channel-types
(
keyword
channel
)))))
(
def
days-of-week
(
def
^
:const
days-of-week
"Simple `vector` of the days in the week used for reference and lookups.
NOTE: order is important here!!
...
...
@@ -59,7 +59,7 @@
{
:id
"fri"
:name
"Fri"
}
,
{
:id
"sat"
:name
"Sat"
}])
(
def
times-of-day
(
def
^
:const
times-of-day
[{
:id
"morning"
:name
"Morning"
:realhour
8
}
,
{
:id
"midday"
:name
"Midday"
:realhour
12
}
,
{
:id
"afternoon"
:name
"Afternoon"
:realhour
16
}
,
...
...
@@ -92,15 +92,13 @@
(
post-select
[
_
{
:keys
[
id
creator_id
details
]
:as
pulse-channel
}]
(
map->PulseChannelInstance
(
u/assoc*
pulse-channel
;; don't include `:emails`, we use that purely internally
:details
(
dissoc
details
:emails
)
;; here we recombine user details w/ freeform emails
:recipients
(
delay
(
into
(
or
(
->>
(
:emails
details
)
(
mapv
#
(
assoc
{}
:email
%
)))
[])
(
db/sel
:many
[
User
:id
:email
:first_name
:last_name
]
(
k/where
{
:id
[
in
(
k/subselect
PulseChannelRecipient
(
k/fields
:user_id
)
(
k/where
{
:pulse_channel_id
id
}))]})))))))
(
assoc
pulse-channel
;; don't include `:emails`, we use that purely internally
:details
(
dissoc
details
:emails
)
;; here we recombine user details w/ freeform emails
:recipients
(
delay
(
into
(
mapv
(
partial
array-map
:email
)
(
:emails
details
))
(
db/sel
:many
[
User
:id
:email
:first_name
:last_name
]
(
k/where
{
:id
[
in
(
k/subselect
PulseChannelRecipient
(
k/fields
:user_id
)
(
k/where
{
:pulse_channel_id
id
}))]})))))))
(
pre-cascade-delete
[
_
{
:keys
[
id
]}]
(
db/cascade-delete
PulseChannelRecipient
:pulse_channel_id
id
)))
...
...
@@ -108,7 +106,7 @@
(
extend-ICanReadWrite
PulseChannelEntity
:read
:always,
:write
:superuser
)
;; ##
Helper
Functions
;; ##
Persistence
Functions
(
defn
update-recipients!
"Update the `PulseChannelRecipients` for PULSE-CHANNEL.
...
...
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