Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lag en side til hver matvare, på både norsk og engelsk
Co-authored-by: Magnar Sveen <magnar.sveen@mattilsynet.no>
- Loading branch information
Showing
3 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
[] | ||
[{:db/ident :food/id | ||
:db/valueType :db.type/string | ||
:db/cardinality :db.cardinality/one}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
(ns matvaretabellen.ingest | ||
(:require [datomic-type-extensions.api :as d] | ||
[matvaretabellen.pages :as pages])) | ||
[matvaretabellen.pages :as pages] | ||
[matvaretabellen.urls :as urls])) | ||
|
||
(defn on-started [_foods-conn powerpack-app] | ||
@(d/transact (:datomic/conn powerpack-app) pages/static-pages)) | ||
(defn get-food-pages [db] | ||
(->> (d/q '[:find ?food-id ?food-name | ||
:where | ||
[?f :food/id ?food-id] | ||
[?f :food/name ?food-name]] | ||
db) | ||
(mapcat | ||
(fn [[id i18n-names]] | ||
(for [[locale food-name] i18n-names] | ||
{:page/uri (urls/get-url locale food-name) | ||
:page/kind :page.kind/food | ||
:page/locale locale | ||
:food/id id}))))) | ||
|
||
(defn on-started [foods-conn powerpack-app] | ||
(->> pages/static-pages | ||
(concat (get-food-pages (d/db foods-conn))) | ||
(d/transact (:datomic/conn powerpack-app)) | ||
deref)) | ||
|
||
(defn create-tx [_file-name datas] | ||
datas) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters