Skip to content

Commit 78cc27c

Browse files
Add kind column to db
1 parent b9558fd commit 78cc27c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE profile
2+
ADD COLUMN kind TEXT NOT NULL DEFAULT 'flamegraph';

src/flamebin/db.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
(defn insert-profile [profile]
5252
(m/assert Profile profile)
53-
(let [{:keys [id file_path profile_type sample_count owner upload_ts
53+
(let [{:keys [id file_path profile_type kind sample_count owner upload_ts
5454
edit_token config is_public]} profile]
5555
(log/infof "Inserting profile %s from %s" id owner)
5656
(with-locking (:lock @db)
@@ -59,6 +59,7 @@
5959
{:id id
6060
:file_path file_path
6161
:profile_type (name profile_type)
62+
:kind (name kind)
6263
:upload_ts (str upload_ts)
6364
:sample_count sample_count
6465
:is_public is_public
@@ -74,21 +75,21 @@
7475

7576
(defn list-profiles []
7677
(with-locking (:lock @db)
77-
(->> (jdbc/execute! @db ["SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, is_public FROM profile"])
78+
(->> (jdbc/execute! @db ["SELECT id, file_path, profile_type, kind, sample_count, owner, config, upload_ts, is_public FROM profile"])
7879
(mapv #(-> (unqualify-keys %)
7980
(assoc :edit_token nil)
8081
(coerce Profile))))))
8182

8283
(defn list-public-profiles [n]
8384
(with-locking (:lock @db)
84-
(->> (jdbc/execute! @db ["SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, is_public, edit_token FROM profile
85+
(->> (jdbc/execute! @db ["SELECT id, file_path, profile_type, kind, sample_count, owner, config, upload_ts, is_public, edit_token FROM profile
8586
WHERE is_public = 1 ORDER BY upload_ts DESC LIMIT ?" n])
8687
(mapv #(-> (unqualify-keys %)
8788
(coerce Profile))))))
8889

8990
(defn get-profile [profile-id]
9091
(with-locking (:lock @db)
91-
(let [q ["SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, edit_token, is_public FROM profile WHERE id = ?" profile-id]
92+
(let [q ["SELECT id, file_path, profile_type, kind, sample_count, owner, config, upload_ts, edit_token, is_public FROM profile WHERE id = ?" profile-id]
9293
row (some-> (jdbc/execute-one! @db q)
9394
unqualify-keys
9495
(coerce Profile))]

src/flamebin/dto.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
:id :nano-id
2424
:file_path [:and {:gen/fmap #(str % ".dpf")} :string]
2525
:profile_type :keyword
26+
:kind [:enum :flamegraph :diffgraph]
2627
:sample_count [:maybe nat-int?]
2728
:owner [:maybe :string]
2829
:edit_token [:maybe :string]

0 commit comments

Comments
 (0)