The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-02-14

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:26 Grinnz the grouping and sorting may be doable in the query itself
00:31 s1037989 I know this isn't the place for SQL...  but could I do a query like "SELECT uid,date,value FROM measurements GROUP BY uid" and be able to pick the first (or last) value per group in which each group is sorted by date?
00:33 Grinnz http://stackoverflow.com/a/12608528
00:34 Grinnz the solution for such a thing is very specific to the database you use, but in SQLite, you should be able to do `SELECT uid, MAX(date), value FROM measurements GROUP BY uid`
00:34 Grinnz or MIN
00:36 s1037989 Oh man!!!  That is EXACTLY what I needed.  I don't know why but I just didn't think I could do this with SQL.  Been trying to solve it with Perl.  This is fantastic!  Thanks soo much!!!
00:36 Grinnz if that doesn't work, you'll need a little more complicated query (like that answer shows)
00:36 Grinnz but its doable in SQL nonetheless
00:37 s1037989 Yep your example is perfect.  I don't know why I didn't think min/max could be applied to date.  Didn't even cross my mind!
00:38 Grinnz also, I noticed DBD::SQLite finally put out a new version, with json support
00:38 s1037989 Alright!!  Everyone is finally supporting JSON!!  :D
00:39 Grinnz new version of Mojo::SQLite will be coming sometime soon ;)
00:41 s1037989 Oh good!  Cuz that's exactly what I'm using!!  :D
00:43 bradjm joined #mojo
00:51 good_news_everyon joined #mojo
00:51 good_news_everyon [mojo] kraih tagged v6.46 at c540869: https://git.io/vgyc1
00:51 good_news_everyon left #mojo
00:51 good_news_everyon joined #mojo
00:51 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgycS
00:51 good_news_everyon mojo/master 6a68561 Sebastian Riedel: bump version
00:51 good_news_everyon left #mojo
00:59 lluad joined #mojo
01:37 PryMar56 joined #mojo
01:53 mspo mm sqlite
01:53 bzero joined #mojo
01:55 sri new idea for scheduled jobs https://github.com/kraih/minion/issues/24#issuecomment-183792237
02:00 mspo sri: you could review the rules for amazon lambda periodic jobs
02:01 mspo http://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html
02:03 sri perhaps if there was a way to purge all periodic jobs at once it would be comfortable to use
02:04 sri in the traditional system you'd restart the scheduler daemon
02:04 sri here you could purge all recurring jobs and then enqueue the new ones
02:05 sri only problem is active or failed recurring jobs
02:06 sri i guess they could just get purged too
02:06 sri the active job will finish, and just leave no trace when it is done
02:06 sri and failed doesn't matter too much anyway
02:06 mspo sri: I was thinking today about an archive mechanism
02:07 mspo sri: you could "archive" jobs into another part of the db and need to add a command line switch to view them, etc
02:10 punter joined #mojo
02:10 sri sure, doesn't seem worth the trouble though
02:14 disputin joined #mojo
02:31 zivester joined #mojo
03:06 mspo does mojo have an hmac sha256?
03:07 noganex_ joined #mojo
03:07 sri no
03:11 cpan_mojo Statocles-0.069 by PREACTION https://metacpan.org/release/PREACTION/Statocles-0.069
03:14 asarch joined #mojo
03:19 Grinnz https://metacpan.org/pod/Digest::SHA#hmac_sha256-data-key
03:26 disputin joined #mojo
03:33 disputin joined #mojo
03:34 disputin joined #mojo
03:41 disputin joined #mojo
03:47 disputin joined #mojo
03:48 disputin joined #mojo
03:55 disputin joined #mojo
03:55 disputin joined #mojo
03:59 mcsnolte joined #mojo
04:02 disputin joined #mojo
04:02 disputin joined #mojo
04:10 disputin joined #mojo
04:10 disputin joined #mojo
04:17 disputin joined #mojo
04:17 disputin joined #mojo
04:24 disputin joined #mojo
04:24 disputin joined #mojo
04:30 disputin joined #mojo
04:30 disputin joined #mojo
04:37 disputin joined #mojo
04:37 disputin joined #mojo
04:44 disputin joined #mojo
04:45 disputin joined #mojo
04:45 kaare joined #mojo
04:51 disputin joined #mojo
04:51 disputin joined #mojo
04:58 disputin joined #mojo
04:58 disputin joined #mojo
05:05 disputin joined #mojo
05:06 disputin joined #mojo
05:13 disputin joined #mojo
05:13 disputin joined #mojo
05:18 Ralesk joined #mojo
05:20 disputin joined #mojo
05:26 disputin joined #mojo
05:32 disputin joined #mojo
05:39 disputin joined #mojo
05:41 jberger sri: that's an interesting idea and we should talk about it more tomorrow
05:41 jberger nn
05:45 disputin joined #mojo
05:52 disputin joined #mojo
05:58 disputin joined #mojo
06:05 disputin joined #mojo
06:11 disputin joined #mojo
06:18 disputin joined #mojo
06:24 disputin joined #mojo
06:31 disputin joined #mojo
06:31 disputin joined #mojo
06:37 disputin joined #mojo
06:38 disputin joined #mojo
06:44 disputin joined #mojo
06:44 disputin joined #mojo
06:49 disputin joined #mojo
06:50 disputin joined #mojo
06:56 disputin joined #mojo
06:56 disputin joined #mojo
07:02 disputin joined #mojo
07:02 disputin joined #mojo
07:08 disputin joined #mojo
07:08 dabudabu Sure is disputin in here
07:08 disputin joined #mojo
07:15 disputin joined #mojo
07:15 disputin joined #mojo
07:20 disputin joined #mojo
07:21 disputin joined #mojo
07:27 disputin joined #mojo
07:27 disputin joined #mojo
07:33 disputin joined #mojo
07:33 disputin joined #mojo
07:38 disputin joined #mojo
07:39 disputin joined #mojo
07:45 disputin joined #mojo
07:45 disputin joined #mojo
07:51 disputin joined #mojo
07:51 disputin joined #mojo
07:57 disputin joined #mojo
07:57 disputin joined #mojo
08:01 Averna joined #mojo
08:03 disputin joined #mojo
08:03 disputin joined #mojo
08:09 disputin joined #mojo
08:10 disputin joined #mojo
08:12 Vandal joined #mojo
08:16 disputin joined #mojo
08:16 disputin joined #mojo
08:22 disputin joined #mojo
08:22 disputin joined #mojo
08:28 disputin joined #mojo
08:28 disputin joined #mojo
08:34 disputin joined #mojo
08:34 disputin joined #mojo
08:40 disputin joined #mojo
08:41 disputin joined #mojo
08:47 disputin joined #mojo
08:47 disputin joined #mojo
08:50 pink_mist oh wow, disputin can't stay connected at all :<
08:53 disputin joined #mojo
08:53 disputin joined #mojo
08:59 disputin joined #mojo
08:59 disputin joined #mojo
09:00 FloydATC joined #mojo
09:03 FloydATC What is the "proper" way to break out of a Mojo::IOLoop->delay? Something went wrong, I sent a redirect_to() and then what?
09:04 FloydATC Simply return out of the action?
09:05 disputin joined #mojo
09:05 disputin joined #mojo
09:05 pink_mist if something went wrong I'd usually signal an error by die()ing .. but maybe that's just me :P
09:06 pink_mist I'd assume returning would be fine?
09:06 FloydATC it's just a duplicate db record, doesn't warrant death or even a log message
09:06 FloydATC user error
09:07 FloydATC a polite message to that effect is served, I just want to exit the loop gracefully
09:07 batman FloydATC: return $c->render(...); so yes: return instead of doing $delay->begin / pass
09:08 FloydATC So the IOloop simply goes out of scope and disappears, it doesn't linger somewhere?
09:08 batman (nevermind the render(). just an example)
09:08 batman FloydATC: no. the IOLoop is still there, but the Mojo::IOLoop::Delay object gets garbage collected
09:09 FloydATC Right, sorry
09:10 FloydATC Still trying to wrap my head around exactly how things work and I just wanted to make sure I don't leak resources by simply doing a return
09:11 disputin joined #mojo
09:11 disputin joined #mojo
09:17 disputin joined #mojo
09:17 disputin joined #mojo
09:23 disputin joined #mojo
09:24 disputin joined #mojo
09:24 FloydATC I'm a little confused about variable scoping too, here's what seems to happen: http://pastebin.com/sSvrdagb
09:24 FloydATC Why is my $var only visible in the first block, not the second?
09:26 FloydATC Oh no, nevermind
09:26 FloydATC stupid copy/paste error
09:30 disputin joined #mojo
09:30 disputin joined #mojo
09:36 disputin joined #mojo
09:37 disputin joined #mojo
09:43 disputin joined #mojo
09:43 disputin joined #mojo
09:49 disputin joined #mojo
09:51 disputin joined #mojo
09:56 disputin joined #mojo
09:57 disputin joined #mojo
10:02 disputin joined #mojo
10:04 disputin joined #mojo
10:09 disputin joined #mojo
10:10 disputin joined #mojo
10:15 disputin joined #mojo
10:17 disputin joined #mojo
10:22 disputin joined #mojo
10:24 disputin joined #mojo
10:41 Trelane joined #mojo
11:05 jontaylor joined #mojo
11:11 stryx`_ joined #mojo
11:18 stryx` joined #mojo
12:23 mdom_ joined #mojo
12:28 mdom joined #mojo
12:37 stryx` joined #mojo
13:21 stryx` joined #mojo
14:21 lluad joined #mojo
14:31 asarch joined #mojo
15:13 zivester joined #mojo
15:23 gryphon joined #mojo
15:38 PryMar56 joined #mojo
15:47 * sri closes the validation issues #906 and #907 on github
16:05 captbipto1 joined #mojo
16:09 sri jberger: think it's doable https://github.com/kraih/minion/issues/24#issuecomment-183909191
16:09 sri needs one or two new methods in Minion::Backend::* though
16:10 sri one for sync, and maybe one to reset jobs
16:11 sri sync would take the list of recurring jobs, check which ones already are in the database, then remove unknown recurring jobs, and add the ones not yet in the database
16:12 sri might be rather inefficient, but each worker would only do it during startup once
16:12 sri and there shouldn't be more than maybe 100 recurring jobs... so meh
16:13 sri desription is also pretty easy... recurring jobs just never transition to "finished", they get reset to "inactive" every time instead
16:20 sri omg, i actually saw good programming advice on hackernews!!!
16:21 sri it was for ruby, but works in mojolicious too, for debugging long method chains
16:22 sri $c->foo->bar->baz->yada
16:22 sri somewhere in that chain is a problem, and you don't know where
16:23 sri you could detangle the chain, or just put ->tap calls in there
16:23 sri $c->foo->bar->tap(sub { ...debug stuff... })->baz->yada
16:23 jberger ah nice
16:49 * sri is not working on minion#24 though, just loud thinking
16:49 sri if anyone else wants to give it a try
17:41 bowtie_ joined #mojo
18:31 Grinnz joined #mojo
18:35 sri interesting to see this grow up https://github.com/kennethreitz/records
18:35 sri he decided to support multiple databases after all... through SQLAlchemy
18:52 Grinnz_ joined #mojo
19:18 Grinnz hmm.. I don't think Mojo::Pg's json interface is going to work for Mojo::SQLite :(
19:18 Grinnz I don't believe there's any "type" of the returned data i can use to find if a column was json
19:19 Grinnz there isn't really a 'json' type to begin with
19:19 sri maybe make it ->expand('column_name') then
19:19 Grinnz yeah, that could work
19:51 bowtie_ joined #mojo
20:00 Grinnz now i'm wondering about the use of from_json and to_json... im guessing on insert the json text gets utf-8 encoded like any other string? what about on select?
20:01 Grinnz i'm concerned because while json in sqlite is currently just a text field, so should get encoded/decoded like normal, if they add a binary encoding it may come back as raw utf-8
20:01 Grinnz as that would be stored in a sqlite blob
20:04 Grinnz maybe if there's a binary encoding, i would just suggest that it gets stored as text-type, then it should come back as text too, because sqlite is funny like that
20:04 Grinnz hrm but it would probably be required to be stored as blob :/
20:12 Grinnz oh well, i'll just implement this for now, if they do that i'll figure it out then
20:38 Grinnz json support looks good :) https://travis-ci.org/Grinnz/Mojo-SQLite/builds/109216466
20:44 Grinnz i'm wondering if maybe i should make it expand_json or expand(json => 'column') or something, since SQLite does not have a "column type" i can use in the future to disambiguate
20:46 sri a few more things you might want to take https://metacpan.org/diff/file?target=SRI%2FMojo-Pg-2.23%2F&amp;source=SRI%2FMojo-Pg-2.15%2F
20:50 Grinnz i wonder if DBD::SQLite sets TYPE in the handle, i might be able to use that
20:59 Grinnz just sets it to the string type of the column which could be anything, guess not
21:02 stephan48 didn't someone of you wrote a module for mocking databases?
21:31 sugar__ joined #mojo
21:44 Grinnz sri, does your ->tables method list temporary tables?
21:47 sri whatever DBD::Pg lists
22:02 Grinnz looks like DBD::SQLite returns entries for indexes by default, lol
22:02 Grinnz if i specify type as TABLE,VIEW,LOCAL_TEMPORARY it looks like it returns the right things
22:03 sri lol
22:07 Grinnz oh ffs
22:07 Grinnz indexes on temporary tables are returned as LOCAL TEMPORARY
22:08 Grinnz it still returns the table name but it just means theres duplicates... whatever
22:09 Grinnz LOCAL TEMPORARY not LOCAL_TEMPORARY, also
22:11 Grinnz if you pass TABLE,VIEW,MATERIALIZED VIEW,LOCAL TEMPORARY you should get what you need from DBD::Pg without having to do the grep
22:16 sri Grinnz: i don't think that is true
22:42 sri yea, it's not true
22:43 Grinnz just a guess, based on the docs
22:55 cpan_mojo Mojo-SQLite-0.020 by DBOOK https://metacpan.org/release/DBOOK/Mojo-SQLite-0.020
23:43 sri are there reasons not to union all these two queries? https://github.com/kraih/minion/commit/80e94cc46d7112383ef9f57dd08b73e4b0c5653b
23:45 sri there seems to be no measurable performance difference

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary