<commit_before>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2019 <NAME> <<EMAIL>>

(ns uxbox.api.pages
  (:require [clojure.spec.alpha :as s]
            [struct.core :as st]
            [promesa.core :as p]
            [uxbox.services :as sv]
            [uxbox.http.response :as rsp]
            [uxbox.util.spec :as us]
            [uxbox.util.uuid :as uuid]))

;; --- Common Specs

(s/def ::id ::us/uuid)
(s/def ::name string?)
(s/def ::project ::us/uuid)
(s/def ::version (s/and integer? pos?))
(s/def ::data any?)
(s/def ::metadata any?)

;; --- List Pages

(s/def ::list-pages|query
  (s/keys :req-un [::project]))

(defn list-pages
  {:parameters {:query ::list-pages|query}
   :validation :spec}
  [{:keys [user parameters]}]
  (let [project (get-in parameters [:query :project])
        message {:user user :project project :type :list-pages-by-project}]
    (-> (sv/query message)<commit_msg>:bug: Fix page version spec.<commit_after>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2019 <NAME> <<EMAIL>>

(ns uxbox.api.pages
  (:require [clojure.spec.alpha :as s]
            [struct.core :as st]
            [promesa.core :as p]
            [uxbox.services :as sv]
            [uxbox.http.response :as rsp]
            [uxbox.util.spec :as us]
            [uxbox.util.uuid :as uuid]))

;; --- Common Specs

(s/def ::id ::us/uuid)
(s/def ::name string?)
(s/def ::project ::us/uuid)
(s/def ::version int?)
(s/def ::data any?)
(s/def ::metadata any?)

;; --- List Pages

(s/def ::list-pages|query
  (s/keys :req-un [::project]))

(defn list-pages
  {:parameters {:query ::list-pages|query}
   :validation :spec}
  [{:keys [user parameters]}]
  (let [project (get-in parameters [:query :project])
        message {:user user :project project :type :list-pages-by-project}]
    (-> (sv/query message)
{'fraction_non_alphanumeric': 0.17562557924003708, 'fraction_numerical': 0.0074142724745134385, 'mean_word_length': 2.8348134991119007, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6062675', 'n_tokens_mistral': 769, 'n_tokens_neox': 745, 'n_words': 237}