From a0bf0165a3b4ce5454cbcd724decd4df5d360ee8 Mon Sep 17 00:00:00 2001 From: Rafael Delboni Date: Mon, 29 Jul 2024 21:45:01 -0300 Subject: [PATCH 1/3] feat(social): adds db for latest & top author interactions --- docker/docker-compose.yml | 2 - .../clj/docs/backend/adapters/db/postgres.clj | 21 +++++ src/codes/clj/docs/backend/db/postgres.clj | 42 ++++++++++ .../clj/docs/backend/schemas/db/postgres.clj | 3 + .../clj/docs/backend/schemas/model/social.clj | 6 ++ .../clj/docs/backend/db/postgres_test.clj | 29 ++++++- .../clj/docs/backend/util/db/postgres.clj | 16 ++++ .../backend/adapters/db/postgres_test.clj | 80 ++++++++++++++++++- 8 files changed, 195 insertions(+), 4 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 35b6ffe..a0767d1 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.7" - services: db: image: postgres:14 diff --git a/src/codes/clj/docs/backend/adapters/db/postgres.clj b/src/codes/clj/docs/backend/adapters/db/postgres.clj index 4e2c490..ec18b4c 100644 --- a/src/codes/clj/docs/backend/adapters/db/postgres.clj +++ b/src/codes/clj/docs/backend/adapters/db/postgres.clj @@ -12,6 +12,15 @@ :author/avatar-url avatar-url :author/created-at created-at}) +(defn db->author+interaction + {:malli/schema [:=> [:cat [:sequential schemas.db/Author+InteractionsRow]] + [:sequential schemas.model.social/Author+Interactions]]} + [db-rows] + (map (fn [{:keys [interactions] :as author}] + (assoc (db->author author) + :author/interactions interactions)) + db-rows)) + (defn db->note {:malli/schema [:=> [:cat [:maybe schemas.db/Row]] [:maybe schemas.model.social/Note]]} [{:keys [id definition-id body created author-id] :as note}] @@ -97,3 +106,15 @@ [:maybe schemas.model.social/Social]]} [db-rows] (first (db->socials db-rows))) + +(defn db->any-socials + {:malli/schema [:=> [:cat [:sequential schemas.db/Row]] + [:maybe [:sequential schemas.model.social/AnySocial]]]} + [db-rows] + (let [notes (db->notes db-rows) + examples (db->examples db-rows) + see-alsos (db->see-alsos db-rows)] + (concat + (seq notes) + (seq examples) + (seq see-alsos)))) diff --git a/src/codes/clj/docs/backend/db/postgres.clj b/src/codes/clj/docs/backend/db/postgres.clj index 2cd6ed9..bdccfbc 100644 --- a/src/codes/clj/docs/backend/db/postgres.clj +++ b/src/codes/clj/docs/backend/db/postgres.clj @@ -293,3 +293,45 @@ sql/format) (execute! db) adapters/db->social-definition)) + +(defn get-top-authors + {:malli/schema [:=> [:cat :int schemas.types/DatabaseComponent] + [:maybe [:sequential schemas.model.social/Author+Interactions]]]} ; todo out schema + [limit db] + (->> (-> (sql.helpers/select + :author/* + [[:count :social/id] :interactions]) + (sql.helpers/from [(sql.helpers/union-all + (-> (sql.helpers/select + [:note/note-id :id] + [:note/author-id :author-id]) + (sql.helpers/from :note)) + (-> (sql.helpers/select + [:example-edit/example-edit-id :id] + [:example-edit/author-id :author-id]) + (sql.helpers/from :example-edit)) + (-> (sql.helpers/select + [:see-also/see-also-id :id] + [:see-also/author-id :author-id]) + (sql.helpers/from :see-also))) :social]) + (sql.helpers/join :author + [:= :social/author-id :author/author-id]) + (sql.helpers/group-by :author/author-id) + (sql.helpers/limit limit) + sql/format) + (execute! db) + adapters/db->author+interaction)) + +(defn get-latest-interactions + {:malli/schema [:=> [:cat :int schemas.types/DatabaseComponent] + [:maybe [:sequential schemas.model.social/AnySocial]]]} + [limit db] + (->> (-> (sql.helpers/union-all + get-note-query + get-example-query + get-see-also-query) + (sql.helpers/order-by :created) + (sql.helpers/limit limit) + sql/format) + (execute! db) + adapters/db->any-socials)) diff --git a/src/codes/clj/docs/backend/schemas/db/postgres.clj b/src/codes/clj/docs/backend/schemas/db/postgres.clj index 88026cc..30c7e0f 100644 --- a/src/codes/clj/docs/backend/schemas/db/postgres.clj +++ b/src/codes/clj/docs/backend/schemas/db/postgres.clj @@ -44,3 +44,6 @@ :account-source :avatar-url :created-at])) + +(def Author+InteractionsRow + (mu/assoc AuthorRow :interactions :int)) diff --git a/src/codes/clj/docs/backend/schemas/model/social.clj b/src/codes/clj/docs/backend/schemas/model/social.clj index 9719669..bca47c6 100644 --- a/src/codes/clj/docs/backend/schemas/model/social.clj +++ b/src/codes/clj/docs/backend/schemas/model/social.clj @@ -111,5 +111,11 @@ [:social/examples [:sequential Example]] [:social/see-alsos [:sequential SeeAlso]]]) +(def AnySocial + [:or Example Note SeeAlso]) + (def Author+Socials (mu/assoc Author [:author/socials {:optional true}] [:sequential Social])) + +(def Author+Interactions + (mu/assoc Author [:author/interactions {:optional true}] :int)) diff --git a/test/integration/codes/clj/docs/backend/db/postgres_test.clj b/test/integration/codes/clj/docs/backend/db/postgres_test.clj index 502645f..1deab29 100644 --- a/test/integration/codes/clj/docs/backend/db/postgres_test.clj +++ b/test/integration/codes/clj/docs/backend/db/postgres_test.clj @@ -4,6 +4,7 @@ [com.stuartsierra.component :as component] [integration.codes.clj.docs.backend.util :as util] [integration.codes.clj.docs.backend.util.db.postgres :as util.db.postgres] + [matcher-combinators.matchers :as m] [parenthesin.components.config.aero :as components.config] [parenthesin.components.db.jdbc-hikari :as components.database] [parenthesin.helpers.malli :as helpers.malli] @@ -71,7 +72,33 @@ :example/author-id)] :social/see-alsos [see-also-1]}]} - (db/get-author+socials "delboni" "github" database)))) + (db/get-author+socials "delboni" "github" database))) + + (flow "check latest top authors in db" + (match? (m/in-any-order + [#:author{:author-id uuid? + :login "not-delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at inst? + :interactions 3} + #:author{:author-id uuid? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me2.jpg" + :created-at inst? + :interactions 3}]) + (util.db.postgres/get-top-authors 10))) + + (flow "check latest social interactions in db" + (match? (m/in-any-order + [#:note{:note-id uuid?} + #:note{:note-id uuid?} + #:example{:example-id uuid?} + #:example{:example-id uuid?} + #:see-also{:see-also-id uuid?} + #:see-also{:see-also-id uuid?}]) + (util.db.postgres/get-latest-interactions 10)))) (defflow see-also-db-test {:init (util/start-system! create-and-start-components!) diff --git a/test/integration/codes/clj/docs/backend/util/db/postgres.clj b/test/integration/codes/clj/docs/backend/util/db/postgres.clj index c8f22be..f696406 100644 --- a/test/integration/codes/clj/docs/backend/util/db/postgres.clj +++ b/test/integration/codes/clj/docs/backend/util/db/postgres.clj @@ -108,3 +108,19 @@ (->> database (db/get-by-definition definition-id) state-flow.api/return))) + +(defn get-top-authors + [limit] + (flow "get top authors with their interactions sum" + [database (state-flow.api/get-state :database)] + (->> database + (db/get-top-authors limit) + state-flow.api/return))) + +(defn get-latest-interactions + [limit] + (flow "get latest social interactions" + [database (state-flow.api/get-state :database)] + (->> database + (db/get-latest-interactions limit) + state-flow.api/return))) diff --git a/test/unit/codes/clj/docs/backend/adapters/db/postgres_test.clj b/test/unit/codes/clj/docs/backend/adapters/db/postgres_test.clj index 7db75ac..2f4fbc7 100644 --- a/test/unit/codes/clj/docs/backend/adapters/db/postgres_test.clj +++ b/test/unit/codes/clj/docs/backend/adapters/db/postgres_test.clj @@ -17,6 +17,10 @@ (properties/for-all [row (mg/generator schemas.db.postgres/AuthorRow)] (m/validate schemas.model.social/Author (adapters/db->author row)))) +(defspec db->author+interaction-test 50 + (properties/for-all [row (mg/generator [:sequential schemas.db.postgres/Author+InteractionsRow])] + (m/validate [:sequential schemas.model.social/Author+Interactions] (adapters/db->author+interaction row)))) + (defspec db->note-test 50 (properties/for-all [row (mg/generator (mu/assoc schemas.db.postgres/FullRow :type [:enum "note"]))] (m/validate schemas.model.social/Note (adapters/db->note row)))) @@ -255,4 +259,78 @@ :created-at #inst "2020-10-23T00:00:00.000-00:00" :definition-id "clojure.core/disj2"}]))))) - +(deftest db->any-socials-test + (testing "should list of any social parsed in db-rows" + (is (match? [#:note{:note-id #uuid "d9564b50-98f8-4c04-a668-bd24c1241e34" + :definition-id "clojure.core/disj" + :body "my note about this function." + :created-at #inst "2020-10-23T00:00:00.000-00:00" + :author #:author{:author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at #inst "2020-10-23T00:00:00.000-00:00"}} + #:note{:note-id #uuid "7aac759f-35dc-456c-9611-44589336560c" + :definition-id "clojure.core/disj" + :body "my second note about this function." + :created-at #inst "2020-10-23T00:00:00.000-00:00" + :author #:author{:author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at #inst "2020-10-23T00:00:00.000-00:00"}} + #:example{:example-id #uuid "0f0a0fe8-7147-4d45-b212-3a32bc37d07a" + :definition-id "clojure.core/disj" + :body "my example about this function. edited again" + :created-at #inst "2020-10-23T03:00:00.000-00:00" + :author #:author{:author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at #inst "2020-10-23T00:00:00.000-00:00"} + :editors + [{:author/author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :author/login "delboni" + :author/account-source "github" + :author/avatar-url "https://my.pic.com/me.jpg" + :author/created-at #inst "2020-10-23T00:00:00.000-00:00" + :editor/edited-at #inst "2020-10-23T01:00:00.000-00:00"} + {:author/author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :author/login "delboni" + :author/account-source "github" + :author/avatar-url "https://my.pic.com/me.jpg" + :author/created-at #inst "2020-10-23T00:00:00.000-00:00" + :editor/edited-at #inst "2020-10-23T02:00:00.000-00:00"} + {:author/author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :author/login "delboni" + :author/account-source "github" + :author/avatar-url "https://my.pic.com/me.jpg" + :author/created-at #inst "2020-10-23T00:00:00.000-00:00" + :editor/edited-at #inst "2020-10-23T03:00:00.000-00:00"}]} + #:example{:example-id #uuid "c9df4a18-ec91-4d3f-9cb2-d65d48db88eb" + :definition-id "clojure.core/disj" + :body "another example about this function." + :created-at #inst "2020-10-23T00:00:00.000-00:00" + :author #:author{:author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at #inst "2020-10-23T00:00:00.000-00:00"} + :editors + [{:author/author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :author/login "delboni" + :author/account-source "github" + :author/avatar-url "https://my.pic.com/me.jpg" + :author/created-at #inst "2020-10-23T00:00:00.000-00:00" + :editor/edited-at #inst "2020-10-23T00:00:00.000-00:00"}]} + #:see-also{:see-also-id #uuid "b8a824b9-6a3a-4a10-a318-58313637ecb6" + :definition-id "clojure.core/disj" + :definition-id-to "clojure.core/dissoc" + :created-at #inst "2020-10-23T00:00:00.000-00:00" + :author #:author{:author-id #uuid "387863e6-e32b-4d4b-8ec5-8cf4dab7e048" + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic.com/me.jpg" + :created-at + #inst "2020-10-23T00:00:00.000-00:00"}}] + (adapters/db->any-socials db-rows))))) From bd3840c4c8cb5e9321c3ad37c64b180420352e72 Mon Sep 17 00:00:00 2001 From: Rafael Delboni Date: Mon, 29 Jul 2024 22:01:16 -0300 Subject: [PATCH 2/3] feat(social): adds db order-by on new queries --- src/codes/clj/docs/backend/db/postgres.clj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/codes/clj/docs/backend/db/postgres.clj b/src/codes/clj/docs/backend/db/postgres.clj index bdccfbc..675ec1b 100644 --- a/src/codes/clj/docs/backend/db/postgres.clj +++ b/src/codes/clj/docs/backend/db/postgres.clj @@ -296,7 +296,7 @@ (defn get-top-authors {:malli/schema [:=> [:cat :int schemas.types/DatabaseComponent] - [:maybe [:sequential schemas.model.social/Author+Interactions]]]} ; todo out schema + [:maybe [:sequential schemas.model.social/Author+Interactions]]]} [limit db] (->> (-> (sql.helpers/select :author/* @@ -317,6 +317,7 @@ (sql.helpers/join :author [:= :social/author-id :author/author-id]) (sql.helpers/group-by :author/author-id) + (sql.helpers/order-by [:interactions :desc]) (sql.helpers/limit limit) sql/format) (execute! db) @@ -330,7 +331,7 @@ get-note-query get-example-query get-see-also-query) - (sql.helpers/order-by :created) + (sql.helpers/order-by [:created :desc]) (sql.helpers/limit limit) sql/format) (execute! db) From 14fd876548068514d15b967e9edc94b979270c22 Mon Sep 17 00:00:00 2001 From: Rafael Delboni Date: Fri, 2 Aug 2024 22:01:26 -0300 Subject: [PATCH 3/3] feat(social): adds wireout model/adapter/controller/tests --- .../clj/docs/backend/adapters/social.clj | 29 +++++++ .../clj/docs/backend/controllers/social.clj | 12 +++ .../clj/docs/backend/ports/http_in/social.clj | 16 ++++ src/codes/clj/docs/backend/routes.clj | 19 ++++- .../clj/docs/backend/schemas/model/social.clj | 2 +- .../docs/backend/schemas/wire/out/social.clj | 6 ++ .../codes/clj/docs/backend/social_test.clj | 77 +++++++++++++++++++ .../clj/docs/backend/adapters/social_test.clj | 10 +++ 8 files changed, 169 insertions(+), 2 deletions(-) diff --git a/src/codes/clj/docs/backend/adapters/social.clj b/src/codes/clj/docs/backend/adapters/social.clj index 255a9f0..d660607 100644 --- a/src/codes/clj/docs/backend/adapters/social.clj +++ b/src/codes/clj/docs/backend/adapters/social.clj @@ -33,6 +33,16 @@ :avatar-url avatar-url :created-at created-at}) +(defn author-interaction->model->wire + {:malli/schema [:=> [:cat [:sequential schemas.model.social/Author+Interactions]] + [:sequential schemas.wire.out.social/Author+Interactions]]} + [author+interactions] + (->> author+interactions + (map (fn [{:author/keys [interactions] :as author}] + (assoc (author->model->wire author) + :interactions interactions))) + (sort-by :interactions #(compare %2 %1)))) + (defn editor->model->wire {:malli/schema [:=> [:cat schemas.model.social/Editor] schemas.wire.social/Editor]} [{:editor/keys [edited-at] :as author}] @@ -129,3 +139,22 @@ (enc/assoc-some (author->model->wire author) :socials (map social->model->wire socials))) + +(defn any-social->model->wire + {:malli/schema [:=> [:cat [:sequential schemas.model.social/AnySocial]] + [:maybe [:sequential schemas.wire.out.social/AnySocial]]]} + [any-socials] + (let [notes (->> any-socials + (filter #(:note/note-id %)) + (map note->model->wire)) + examples (->> any-socials + (filter #(:example/example-id %)) + (map example->model->wire)) + see-alsos (->> any-socials + (filter #(:see-also/see-also-id %)) + (map see-also->model->wire))] + (->> (concat + (seq notes) + (seq examples) + (seq see-alsos)) + (sort-by :created-at #(compare %2 %1))))) diff --git a/src/codes/clj/docs/backend/controllers/social.clj b/src/codes/clj/docs/backend/controllers/social.clj index c8e6efe..df2d501 100644 --- a/src/codes/clj/docs/backend/controllers/social.clj +++ b/src/codes/clj/docs/backend/controllers/social.clj @@ -86,3 +86,15 @@ [:maybe schemas.model.social/Social]]} [definition-id {:keys [database]}] (db.postgres/get-by-definition definition-id database)) + +(defn get-top-authors + {:malli/schema [:=> [:cat :int schemas.types/Components] + [:maybe [:sequential schemas.model.social/Author+Interactions]]]} + [limit {:keys [database]}] + (db.postgres/get-top-authors limit database)) + +(defn get-latest-interactions + {:malli/schema [:=> [:cat :int schemas.types/Components] + [:maybe [:sequential schemas.model.social/AnySocial]]]} + [limit {:keys [database]}] + (db.postgres/get-latest-interactions limit database)) diff --git a/src/codes/clj/docs/backend/ports/http_in/social.clj b/src/codes/clj/docs/backend/ports/http_in/social.clj index 4b5b296..f8ff19b 100644 --- a/src/codes/clj/docs/backend/ports/http_in/social.clj +++ b/src/codes/clj/docs/backend/ports/http_in/social.clj @@ -155,3 +155,19 @@ :notes [] :examples [] :see-alsos []})}) + +(defn get-top-authors + [{{{:keys [limit]} :query} :parameters + components :components}] + {:status 200 + :body (-> (or limit 10) + (controllers.social/get-top-authors components) + adapters.social/author-interaction->model->wire)}) + +(defn get-latest-interactions + [{{{:keys [limit]} :query} :parameters + components :components}] + {:status 200 + :body (-> (or limit 10) + (controllers.social/get-latest-interactions components) + adapters.social/any-social->model->wire)}) diff --git a/src/codes/clj/docs/backend/routes.clj b/src/codes/clj/docs/backend/routes.clj index de3af9b..f83180c 100644 --- a/src/codes/clj/docs/backend/routes.clj +++ b/src/codes/clj/docs/backend/routes.clj @@ -169,7 +169,24 @@ :responses {200 {:body schemas.wire.out.social/Social} 404 {:body :string} 500 {:body :string}} - :handler ports.http-in.social/get-by-definition}}]]] + :handler ports.http-in.social/get-by-definition}}]] + + ["/query" + ["/top-authors" + {:get {:summary "get top contributing author list" + :parameters {:query [:map [:limit {:optional true} :int]]} + :responses {200 {:body [:sequential schemas.wire.out.social/Author+Interactions]} + 404 {:body :string} + 500 {:body :string}} + :handler ports.http-in.social/get-top-authors}}] + + ["/latest-interactions" + {:get {:summary "get latest social interactions list" + :parameters {:query [:map [:limit {:optional true} :int]]} + :responses {200 {:body [:sequential schemas.wire.out.social/AnySocial]} + 404 {:body :string} + 500 {:body :string}} + :handler ports.http-in.social/get-latest-interactions}}]]] ["/document" {:swagger {:tags ["document"]}} diff --git a/src/codes/clj/docs/backend/schemas/model/social.clj b/src/codes/clj/docs/backend/schemas/model/social.clj index bca47c6..6255edd 100644 --- a/src/codes/clj/docs/backend/schemas/model/social.clj +++ b/src/codes/clj/docs/backend/schemas/model/social.clj @@ -118,4 +118,4 @@ (mu/assoc Author [:author/socials {:optional true}] [:sequential Social])) (def Author+Interactions - (mu/assoc Author [:author/interactions {:optional true}] :int)) + (mu/assoc Author :author/interactions :int)) diff --git a/src/codes/clj/docs/backend/schemas/wire/out/social.clj b/src/codes/clj/docs/backend/schemas/wire/out/social.clj index bfb2fce..046ad37 100644 --- a/src/codes/clj/docs/backend/schemas/wire/out/social.clj +++ b/src/codes/clj/docs/backend/schemas/wire/out/social.clj @@ -33,5 +33,11 @@ [:examples [:sequential Example]] [:see-alsos [:sequential SeeAlso]]]) +(def AnySocial + [:or Example Note SeeAlso]) + (def Author+Socials (mu/assoc Author [:socials {:optional true}] [:sequential Social])) + +(def Author+Interactions + (mu/assoc Author :interactions :int)) diff --git a/test/integration/codes/clj/docs/backend/social_test.clj b/test/integration/codes/clj/docs/backend/social_test.clj index 9cbb56b..ed3854d 100644 --- a/test/integration/codes/clj/docs/backend/social_test.clj +++ b/test/integration/codes/clj/docs/backend/social_test.clj @@ -158,6 +158,31 @@ (state-flow.server/request! {:method :get :uri "/api/social/author/delboni/github"}))) + (flow "should return top authors" + (match? {:status 200 + :body [{:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string? + :interactions 1}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/top-authors"}))) + + (flow "should return latest interactions" + (match? {:status 200 + :body [{:note-id string? + :definition-id "clojure.core/disj" + :body "my edited note about this function." + :created-at string? + :author {:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string?}}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/latest-interactions"}))) + (flow "should not be able to delete if not allowed" (match? {:status 403 :body "You not allowed to delete this note."} @@ -246,6 +271,26 @@ (state-flow.server/request! {:method :get :uri "/api/social/author/delboni/github"}))) + (flow "should return top authors" + (match? {:status 200 + :body [{:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string? + :interactions 1}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/top-authors"}))) + + (flow "should return latest interactions" + (match? {:status 200 + :body [{:see-also-id see-also-id + :definition-id "clojure.core/disj" + :definition-id-to "clojure.core/dissoc" + :created-at string?}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/latest-interactions"}))) + (flow "should not be able to delete if not allowed" (match? {:status 403 :body "You not allowed to delete this see also."} @@ -386,6 +431,38 @@ (state-flow.server/request! {:method :get :uri "/api/social/author/delboni/github"}))) + (flow "should return top authors" + (match? {:status 200 + :body [{:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string? + :interactions 2}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/top-authors"}))) + + (flow "should return latest interactions" + (match? {:status 200 + :body [{:example-id example-id + :definition-id "clojure.core/disj" + :body "my edited example about this function." + :created-at string? + :editors [{:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string? + :edited-at string?} + {:author-id string? + :login "delboni" + :account-source "github" + :avatar-url "https://my.pic/me.jpg" + :created-at string? + :edited-at string?}]}]} + (state-flow.server/request! {:method :get + :uri "/api/social/query/latest-interactions"}))) + (flow "delete example revision part 1" (state-flow.server/request! {:method :delete :headers {"authorization" (str "Bearer " token)} diff --git a/test/unit/codes/clj/docs/backend/adapters/social_test.clj b/test/unit/codes/clj/docs/backend/adapters/social_test.clj index 2e92e87..f19b378 100644 --- a/test/unit/codes/clj/docs/backend/adapters/social_test.clj +++ b/test/unit/codes/clj/docs/backend/adapters/social_test.clj @@ -28,6 +28,11 @@ (m/validate schemas.wire.social/Author (adapters.social/author->model->wire author)))) +(defspec author-interaction->model->wire-test 50 + (properties/for-all [author+interaction (mg/generator schemas.model.social/Author+Interactions)] + (m/validate [:sequential schemas.wire.out.social/Author+Interactions] + (adapters.social/author-interaction->model->wire [author+interaction])))) + (defspec editor->model->wire-test 50 (properties/for-all [editor (mg/generator schemas.model.social/Editor)] (m/validate schemas.wire.social/Editor @@ -87,3 +92,8 @@ (properties/for-all [author+socials (mg/generator schemas.model.social/Author+Socials)] (m/validate schemas.wire.out.social/Author+Socials (adapters.social/author+socials->model->wire author+socials)))) + +(defspec any-social->model->wire-test 50 + (properties/for-all [any-social (mg/generator schemas.model.social/AnySocial)] + (m/validate [:sequential schemas.wire.out.social/AnySocial] + (adapters.social/any-social->model->wire [any-social]))))