3131 :lock (ReentrantLock. )}
3232 migrate))
3333
34- #_(mount/start #'db)
34+ #_(do ( mount/stop #'db) ( mount/ start #'db) )
3535
3636; ;;; DB interaction
3737
7373
7474(defn list-profiles []
7575 (with-locking (:lock @db)
76- (->> (jdbc/execute! @db [" SELECT id, file_path, profile_type, sample_count, owner, upload_ts, is_public FROM profile" ])
76+ (->> (jdbc/execute! @db [" SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, is_public FROM profile" ])
7777 (mapv #(-> (unqualify-keys %)
7878 (assoc :edit_token nil )
7979 (coerce Profile))))))
8080
8181(defn list-public-profiles [n]
8282 (with-locking (:lock @db)
83- (->> (jdbc/execute! @db [" SELECT id, file_path, profile_type, sample_count, owner, upload_ts, is_public, edit_token FROM profile
83+ (->> (jdbc/execute! @db [" SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, is_public, edit_token FROM profile
8484WHERE is_public = 1 ORDER BY upload_ts DESC LIMIT ?" n])
8585 (mapv #(-> (unqualify-keys %)
8686 (coerce Profile))))))
8787
8888(defn get-profile [profile-id]
8989 (with-locking (:lock @db)
90- (let [q [" SELECT id, file_path, profile_type, sample_count, owner, upload_ts, edit_token, is_public FROM profile WHERE id = ?" profile-id]
90+ (let [q [" SELECT id, file_path, profile_type, sample_count, owner, config, upload_ts, edit_token, is_public FROM profile WHERE id = ?" profile-id]
9191 row (some-> (jdbc/execute-one! @db q)
9292 unqualify-keys
9393 (coerce Profile))]
@@ -103,6 +103,10 @@ WHERE is_public = 1 ORDER BY upload_ts DESC LIMIT ?" n])
103103 (when (zero? update-count)
104104 (raise 404 (format " Profile with ID '%s' not found." profile-id))))))
105105
106+ (defn save-profile-config [profile-id config]
107+ (with-locking (:lock @db)
108+ (sql-helpers/update! @db :profile {:config config} {:id profile-id})))
109+
106110(defn clear-db []
107111 (with-locking (:lock @db)
108112 (.delete (clojure.java.io/file (@config :db :path )))
0 commit comments