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
f80bce03
Unverified
Commit
f80bce03
authored
3 years ago
by
adam-james
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Events BE fixes - Hydrate :collection on timelines and default icon "star" (#21169)
parent
8869361e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/api/timeline.clj
+2
-2
2 additions, 2 deletions
src/metabase/api/timeline.clj
src/metabase/api/timeline_event.clj
+7
-6
7 additions, 6 deletions
src/metabase/api/timeline_event.clj
test/metabase/api/timeline_test.clj
+7
-1
7 additions, 1 deletion
test/metabase/api/timeline_test.clj
with
16 additions
and
9 deletions
src/metabase/api/timeline.clj
+
2
−
2
View file @
f80bce03
...
...
@@ -34,7 +34,7 @@
archived
(
s/maybe
su/BooleanString
)}
(
let
[
archived?
(
Boolean/parseBoolean
archived
)
timelines
(
db/select
Timeline
[
:where
[
:=
:archived
archived?
]])]
(
cond->>
(
hydrate
timelines
:creator
)
(
cond->>
(
hydrate
timelines
:creator
:collection
)
(
=
include
"events"
)
(
map
#
(
timeline-event/include-events-singular
%
{
:events/all?
archived?
})))))
...
...
@@ -48,7 +48,7 @@
end
(
s/maybe
su/TemporalString
)}
(
let
[
archived?
(
Boolean/parseBoolean
archived
)
timeline
(
api/read-check
(
Timeline
id
))]
(
cond->
(
hydrate
timeline
:creator
)
(
cond->
(
hydrate
timeline
:creator
:collection
)
(
=
include
"events"
)
(
timeline-event/include-events-singular
{
:events/all?
archived?
:events/start
(
when
start
(
u.date/parse
start
))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/api/timeline_event.clj
+
7
−
6
View file @
f80bce03
...
...
@@ -30,12 +30,13 @@
{
:status-code
404
})))
(
collection/check-write-perms-for-collection
(
:collection_id
timeline
)))
;; todo: revision system
(
let
[
parsed
(
if
(
nil?
timestamp
)
(
throw
(
ex-info
(
tru
"Timestamp cannot be null"
)
{
:status-code
400
}))
(
u.date/parse
timestamp
))]
(
db/insert!
TimelineEvent
(
assoc
body
:creator_id
api/*current-user-id*
:timestamp
parsed
))))
(
let
[
parsed-timestamp
(
if
(
nil?
timestamp
)
(
throw
(
ex-info
(
tru
"Timestamp cannot be null"
)
{
:status-code
400
}))
(
u.date/parse
timestamp
))
evt
(
merge
body
{
:creator_id
api/*current-user-id*
:timestamp
parsed-timestamp
})]
(
db/insert!
TimelineEvent
(
cond->
evt
(
nil?
icon
)
(
assoc
:icon
"star"
)))))
(
api/defendpoint
GET
"/:id"
"Fetch the [[TimelineEvent]] with `id`."
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/timeline_test.clj
+
7
−
1
View file @
f80bce03
...
...
@@ -34,7 +34,13 @@
(
events-of
(
mt/user-http-request
:rasta
:get
200
"timeline"
)))))
(
testing
"check that we only get archived timelines when `archived=true`"
(
is
(
=
#
{
"Timeline C"
}
(
events-of
(
mt/user-http-request
:rasta
:get
200
"timeline"
:archived
true
))))))))))
(
events-of
(
mt/user-http-request
:rasta
:get
200
"timeline"
:archived
true
)))))
(
testing
"check that `:collection` key is hydrated on each timeline"
(
is
(
=
#
{
id
}
(
->>
(
mt/user-http-request
:rasta
:get
200
"timeline"
)
(
filter
(
comp
#
{
id
}
:collection_id
))
(
map
#
(
get-in
%
[
:collection
:id
]))
set
)))))))))
(
deftest
get-timeline-test
(
testing
"GET /api/timeline/: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