db configurations factored out through db.info
parent
7a5309f075
commit
0c104ca126
|
@ -0,0 +1,15 @@
|
||||||
|
USING: accessors sequences generalizations io.encodings.utf8 db.postgresql parser combinators vocabs.parser db.sqlite
|
||||||
|
io.files ;
|
||||||
|
IN: db.info
|
||||||
|
! having sensative (and likely to change) information directly in source code seems a bad idea
|
||||||
|
: get-info ( -- lines ) current-vocab name>> "vocab:" "/dbinfo.txt" surround utf8 file-lines ;
|
||||||
|
SYNTAX: get-psql-info <postgresql-db> get-info 5 firstn
|
||||||
|
{
|
||||||
|
[ >>host ]
|
||||||
|
[ >>port ]
|
||||||
|
[ >>username ]
|
||||||
|
[ [ f ] [ ] if-empty >>password ]
|
||||||
|
[ >>database ]
|
||||||
|
} spread parsed ;
|
||||||
|
|
||||||
|
SYNTAX: get-sqlite-info get-info first <sqlite-db> parsed ;
|
|
@ -1,5 +1,5 @@
|
||||||
USING: accessors arrays colors.constants combinators db.queries
|
USING: accessors arrays colors.constants combinators db.queries
|
||||||
db.sqlite db.tuples db.types io.files.temp kernel locals math
|
db.info db.tuples db.types kernel locals math
|
||||||
monads persistency sequences sequences.extras ui ui.frp.gadgets
|
monads persistency sequences sequences.extras ui ui.frp.gadgets
|
||||||
ui.frp.layout ui.frp.signals ui.gadgets.labels
|
ui.frp.layout ui.frp.signals ui.gadgets.labels
|
||||||
ui.gadgets.scrollers ui.pens.solid ;
|
ui.gadgets.scrollers ui.pens.solid ;
|
||||||
|
@ -8,7 +8,7 @@ IN: recipes
|
||||||
|
|
||||||
STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
|
STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ;
|
||||||
: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
|
: <recipe> ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ;
|
||||||
"recipes.db" temp-file <sqlite-db> recipe define-db
|
get-psql-info recipe define-db
|
||||||
: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
|
: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
|
||||||
"votes" >>order 30 >>limit swap >>offset get-tuples ;
|
"votes" >>order 30 >>limit swap >>offset get-tuples ;
|
||||||
: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 (head-slice) ;
|
: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 (head-slice) ;
|
||||||
|
|
|
@ -77,5 +77,3 @@ INSTANCE: gadget monad
|
||||||
M: gadget monad-of drop gadget-monad ;
|
M: gadget monad-of drop gadget-monad ;
|
||||||
M: gadget-monad return drop <gadget> swap >>model ;
|
M: gadget-monad return drop <gadget> swap >>model ;
|
||||||
M: gadget >>= output-model [ swap call( x -- y ) ] curry ;
|
M: gadget >>= output-model [ swap call( x -- y ) ] curry ;
|
||||||
|
|
||||||
! Make sure prop removal really destroys normal db code
|
|
Loading…
Reference in New Issue