Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public api #145

Merged
merged 13 commits into from
Dec 27, 2024
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,16 @@ jobs:
uses: tj-actions/changed-files@v41
with:
files: |
webapp/src/cljc/lipas/data/loi.cljc
webapp/src/cljc/lipas/schema/lois.cljc

- name: Generate JSON schema
if: steps.changed-files.outputs.any_changed == 'true'
run: lein run -m lipas.data.loi > loi-schema.json
run: lein run -m lipas.schema.lois > loi-schema.json
working-directory: ./webapp

- name: Generate CSV
if: steps.changed-files.outputs.any_changed == 'true'
run: lein run -m lipas.data.loi csv > loi-schema.csv
run: lein run -m lipas.schema.lois csv > loi-schema.csv
working-directory: ./webapp

- name: Deploy JSON schema to Gist
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ services:
proxy-local:
extends:
service: proxy-base
ports:
- '80:80'
- '443:443'
- '444:444'
links:
- mapproxy
- logstash
Expand Down
26 changes: 26 additions & 0 deletions nginx/proxy_local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,31 @@ server {
location / {
try_files $uri $uri/ /index.html =404;
}
}

server {
listen 444 ssl;
ssl_certificate /certs/server.crt;
ssl_certificate_key /certs/server.key;

# Make search engines ignore anything returned from this proxy
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";

server_name lipas-dev.cc.jyu.fi;

gzip on;
gzip_vary on;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types application/javascript application/json application/transit+json;

# FIXME: Now the path prefix has to be same as in the Reitit tree
location /api-v2/ {
proxy_pass http://172.17.0.1:8091/api-v2/;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
}
}
95 changes: 93 additions & 2 deletions webapp/dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
(reindex-search!)
(reindex-analytics!)
(reset-admin-password! "kissa13")
(reset-password! "[email protected]" "kissa13")

(require '[migratus.core :as migratus])
(migratus/create nil "activities_status" :sql)
Expand Down Expand Up @@ -134,7 +135,7 @@
"Legacy lipas supports only these. Others will be treated as strings"
{"boolean" "boolean"
"numeric" "numberic"
"string" "string"})
"string" "string"})

(doseq [[legacy-prop-k prop-k] legacy-mapping]
(println
Expand All @@ -151,7 +152,7 @@
(get-in prop-types/all [prop-k :description :en])
(name legacy-prop-k))))

(doseq [p new-props
(doseq [p new-props
[type-code m] types/all]
(when (contains? (set (keys (:props m))) p)
(println (str "-- Type " type-code))
Expand All @@ -167,4 +168,94 @@
(name (legacy-mapping-reverse p)))
(get-in types/all [type-code :props p :priority])))))

(require '[malli.provider :as mp])
(require '[lipas.data.types :as types])
(require '[lipas.backend.core :as core])

(def all-sites (atom {}))

(doseq [type-code (keys types/all)]
(let [sites (core/get-sports-sites-by-type-code (db) type-code)]
(swap! all-sites (fn [m]
(reduce (fn [res site] (assoc res (:lipas-id site) site))
m
sites)))))

(mp/provide (vals @all-sites))
(def schema *1)

(require '[lipas.data.sports-sites :as ss])
(require '[malli.core :as m])

(m/schema ss/base-schema)

(m/validate ss/base-schema (-> @all-sites first second))


(m/schema [:string {:min 1 :max 200}])
(m/schema [:string {:min 1 :max 2048}])


(require '[lipas.data.prop-types :as prop-types])

(m/schema [:set (into [:enum] (keys (:opts (:surface-material prop-types/all))))])

(require '[malli.dev])
(malli.dev/start!)

(require '[malli.error :as me])

(def results
(for [[lipas-id site] @all-sites]
[lipas-id (me/humanize (m/explain ss/base-schema site))]))

(->> results
(filter #(some? (second %))))

(:activities (@all-sites 613971))

(count *1)
(@all-sites 613811)

(require '[malli.json-schema :as mj])
(mj/transform ss/base-schema)


(require '[lipas.data.types-new :as types-new])
(require '[lipas.data.types-old :as types-old])

(require '[clojure.set :as set])

(def new-codes (set/difference
(set (keys types-new/all))
(set (keys types-old/all))))

(-> types-new/all
(select-keys new-codes)
(->> (map (juxt first (comp :fi :name second)))
(sort-by first)))

(def merged-codes (set/difference
(set (keys types-old/active))
(set (keys types-new/active))))

(-> types-old/all
(select-keys merged-codes)
(->> (map (juxt first (comp :fi :name second)))
(sort-by first)))

(def merged-to [101 103 106 203 4320 4510 4510])
(-> types-new/all
(select-keys merged-to)
(->> (map (juxt first (comp :fi :name second)))
(sort-by first)))

(require '[lipas.data.prop-types-new :as prop-types-new])
(require '[lipas.data.prop-types-old :as prop-types-old])

(def new-prop-types (set/difference
(set (keys prop-types-new/all))
(set (keys prop-types-old/all))))


)
3 changes: 2 additions & 1 deletion webapp/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
[com.taoensso/timbre "4.10.0"]
[com.cemerick/url "0.1.1"]
[metosin/reitit "0.7.1"]
[metosin/ring-swagger-ui "5.18.2"]
[metosin/spec-tools "0.10.7"]
[metosin/malli "0.16.2"]
[metosin/malli "0.17.0"]

;;; Frontend ;;;
[thheller/shadow-cljs "2.28.16"]
Expand Down
Loading
Loading