Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

637 B
Raw Blame
(ns metabase-enterprise.api-keys.db
  "Application database queries for the enterprise api-keys module. Every function here is a direct Toucan 2 call with
  no additional logic, so the rest of the module never talks to `toucan2.core` itself."
  (:require
   [toucan2.core :as t2]))

(defn insert-usage-logs!
  "Insert the ApiKeyUsageLog `rows` as one batch."
  [rows]
  (t2/insert! :model/ApiKeyUsageLog rows))

(defn delete-usage-logs-occurred-before!
  "Delete the ApiKeyUsageLogs whose `occurred_at` is before `cutoff`, returning the number deleted."
  [cutoff]
  (t2/delete! :model/ApiKeyUsageLog {:where [:< :occurred_at cutoff]}))