site-watcher works again
parent
e951fb773a
commit
e41a7bb6d6
|
@ -65,9 +65,9 @@ TUPLE: reporting-site email url up? changed? last-up? error last-error ;
|
|||
update-tuple ;
|
||||
|
||||
: sites-to-report ( -- seq )
|
||||
"select account.email, site.url, site.up, site.changed, site.last_up, site.error, site.last_error from account, site, watching_site where account.account_name = watching_site.account_name and site.site_id = watching_site.site_id and site.changed = '1'" sql-query
|
||||
"select users.email, site.url, site.up, site.changed, site.last_up, site.error, site.last_error from users, site, watching_site where users.username = watching_site.account_name and site.site_id = watching_site.site_id and site.changed = '1'" sql-query
|
||||
[ [ reporting-site boa ] input<sequence ] map
|
||||
"update site set changed = 'f';" sql-command ;
|
||||
"update site set changed = 0;" sql-command ;
|
||||
|
||||
: insert-site ( url -- site )
|
||||
<site> dup select-tuple [ ] [ dup t >>up? insert-tuple ] ?if ;
|
||||
|
@ -90,3 +90,8 @@ PRIVATE>
|
|||
: watching-sites ( username -- sites )
|
||||
f <watching-site> select-tuples
|
||||
[ site-id>> site new swap >>site-id select-tuple ] map ;
|
||||
|
||||
: site-watcher-path ( -- path ) "site-watcher.db" temp-file ; inline
|
||||
|
||||
: with-site-watcher-db ( quot -- )
|
||||
site-watcher-path <sqlite-db> swap with-db ; inline
|
||||
|
|
|
@ -5,13 +5,6 @@ site-watcher.private kernel db io.directories io.files.temp
|
|||
continuations db.sqlite site-watcher.db.private ;
|
||||
IN: site-watcher.tests
|
||||
|
||||
: site-watcher-path ( -- path ) "site-watcher.db" temp-file ; inline
|
||||
|
||||
[ site-watcher-path delete-file ] ignore-errors
|
||||
|
||||
: with-sqlite-db ( quot -- )
|
||||
site-watcher-path <sqlite-db> swap with-db ; inline
|
||||
|
||||
:: fake-sites ( -- seq )
|
||||
[
|
||||
account ensure-table
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
! Copyright (C) 2009 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alarms arrays calendar combinators
|
||||
combinators.smart continuations debugger http.client
|
||||
init io.streams.string kernel locals math math.parser
|
||||
namespaces sequences site-watcher.db site-watcher.db.private smtp ;
|
||||
combinators.smart continuations debugger http.client fry
|
||||
init io.streams.string kernel locals math math.parser db
|
||||
namespaces sequences site-watcher.db site-watcher.db.private
|
||||
smtp ;
|
||||
IN: site-watcher
|
||||
|
||||
SYMBOL: site-watcher-from
|
||||
|
@ -44,13 +45,13 @@ SYMBOL: running-site-watcher
|
|||
|
||||
PRIVATE>
|
||||
|
||||
: watch-sites ( -- )
|
||||
find-sites check-sites sites-to-report send-reports ;
|
||||
: watch-sites ( db -- )
|
||||
[ find-sites check-sites sites-to-report send-reports ] with-db ;
|
||||
|
||||
: run-site-watcher ( -- )
|
||||
running-site-watcher get [
|
||||
[ watch-sites ] site-watcher-frequency get every
|
||||
running-site-watcher set-global
|
||||
: run-site-watcher ( db -- )
|
||||
[ running-site-watcher get ] dip '[
|
||||
[ _ watch-sites ] site-watcher-frequency get every
|
||||
running-site-watcher set
|
||||
] unless ;
|
||||
|
||||
: stop-site-watcher ( -- )
|
||||
|
|
Loading…
Reference in New Issue