Skip to content

Commit

Permalink
resolve Tamas's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
qnkhuat committed Apr 13, 2023
1 parent 082a3cc commit d894d8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/metabase/api/dashboard.clj
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
(check-parameter-mapping-permissions new-mappings)))

(mu/defn ^:private classify-changes :- [:map
[:to-create [:sequential [:map [:id neg-int?]]]]
[:to-create [:sequential [:map [:id ms/NegativeInt]]]]
[:to-update [:sequential [:map [:id ms/PositiveInt]]]]
[:to-delete [:sequential [:map [:id ms/PositiveInt]]]]]
"Given 2 lists of seq maps changes, where each map an `id` keys,
Expand All @@ -532,7 +532,7 @@
;; to-update changes are new changes with id in the current changes
to-update (filter #(current-change-ids (:id %)) new-changes)
;; to delete changes in current but not new changes
to-delete (filter #(not (new-change-ids (:id %))) current-changes)]
to-delete (remove (comp new-change-ids :id) current-changes)]
{:to-update to-update
:to-delete to-delete
:to-create to-create}))
Expand All @@ -558,7 +558,7 @@
;; transform the card data to the format of the DashboardCard model
;; so update-dashcards! can compare them with existing cards
(dashboard/update-dashcards! dashboard (map dashboard-card/from-parsed-json cards))
;; TODO this is ambiguous, we don't know for sure here that the cards are repositioned
;; TODO this is potentially misleading, we don't know for sure here that the cards are repositioned
(events/publish-event! :dashboard-reposition-cards {:id (:id dashboard) :actor_id api/*current-user-id* :dashcards cards}))

(defn- delete-cards! [dashboard dashcard-ids]
Expand Down
6 changes: 6 additions & 0 deletions src/metabase/util/malli/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
pos-int?
(deferred-tru "value must be an integer greater than zero.")))

(def NegativeInt
"Schema representing an integer than must also be greater than zero."
(mu/with-api-error-message
neg?
(deferred-tru "value must be a negative integer")))

(def PositiveNum
"Schema representing a numeric value greater than zero. This allows floating point numbers and integers."
(mu/with-api-error-message
Expand Down

0 comments on commit d894d8f

Please sign in to comment.