faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<FromGitter> <damianham> > Did you try the ‘dispatch’ method in the channel? That didn’t propagate to redis ⏎ ⏎ The dispatch method requires a client socket which pushing from a controller doesn't have hence I went with publishing directly to Redis.
<FromGitter> <damianham> @elorest I would appreciate anything you can share regarding talking to a CanBus as I am also in that space.
<FromGitter> <drujensen> @damianham ok. We should add someway of sending messages server side.
<FromGitter> <Brodan> > Was supposed to be playing borderlands last night with coworkers but ended up working on the binary messaging protocol for communicating between Vehicle Head Unit and Can Gateway. It's crazy how efficient some of Crystal's low level stuff is. I accomplished in like 76 lines of code what the controls team wrote over 1200 on. ⏎ ⏎ as a total crystal newbie can you ELI5 this?
<FromGitter> <Brodan> is this in regards to that trucking company thats using crystal?
<FromGitter> <drujensen> Yes, @elorest is the lead engineer for Nikola and is using crystal for the dashboard talking to the hardware, sensors, etc. pretty low level stuff that normally would be written in C or ASM.
<FromGitter> <drujensen> Probably should let him explain. 😀
<FromGitter> <sam0x17> what's the fix for this? `Warning: Deprecated Amber::Environment::Logger#initialize. Use `Log` module instead` (0.34.0 upgrade warning)
<FromGitter> <Blacksmoke16> amber needs to update to use `Log` versus `Logger`
<FromGitter> <sam0x17> ah ok -- any way I can suppress this warning for now?
<FromGitter> <Blacksmoke16> `--exclude-warnings <path> Exclude warnings from path (default: lib)`
<FromGitter> <sam0x17> omg thx
<FromGitter> <sam0x17> I was expecting "no"
<FromGitter> <drujensen> I opened an issue if anyone has time to fix it.
<FromGitter> <drujensen> For both granite and amber
<FromGitter> <sam0x17> how do I list multiple paths with that?
<FromGitter> <sam0x17> just list multiple switches, or do like commas or $PATH style ":" between paths or something
<FromGitter> <sam0x17> ?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> maybe call it more than once
<FromGitter> <Blacksmoke16> or really for now *could* just do `--warnings none`
<FromGitter> <sam0x17> calling more than once was the answer -- thanks @Blacksmoke16 !!
<FromGitter> <sam0x17> so for anyone else who wants it, this should get you normal warning behavior ignoring the logger stuff: ⏎ ⏎ ```crystal build --exclude-warnings "/usr/share/crystal/src/" --exclude-warnings "lib"``` ⏎ ⏎ also works with `amber watch`, `crystal spec`, etc. [https://gitter.im/amberframework/amber?at=5e948cc1c52b6a38abe24aed]
<FromGitter> <sam0x17> note: not 100% sure that that path is the same on OSX
<FromGitter> <damianham> > @damianham ok. We should add someway of sending messages server side. ⏎ ⏎ Yes we really need to solve this problem. I don't have time at the moment unfortunately :( However a bit of good news is that I am solving one of my problems with the beginnings of an architecture for plugins so I might be able to make a PR for plugins for Amber before too long.
robacarp has joined #amber
<FromGitter> <drujensen> That is great news.
<FromGitter> <Blacksmoke16> @sardaukar i replied to your comment
<FromGitter> <sam0x17> how to do "where date_field > some_timestamp" queries in granite?
<FromGitter> <sardaukar> @Blacksmoke16 thanks, but I'm still confused :| can't run `shards` on my fork, I get that error message
<FromGitter> <sardaukar> and the spec I added doesn't make sense that is passing, either :|
<FromGitter> <Blacksmoke16> @sardaukar `Post.where(:date_field, :gt, Time.now)`
<FromGitter> <Blacksmoke16> er @sam0x17
<FromGitter> <sam0x17> thx thx
<FromGitter> <Blacksmoke16> @sardaukar, can you share your `shard.yml`?
<FromGitter> <sardaukar> I managed to make it work by removing the `shard.lock` file and re-running `shards`
<FromGitter> <Blacksmoke16> ok
<FromGitter> <sardaukar> even when I saved with `sardaukar/granite` replacing `amberframework/granite` it was still fetching `amberframework/granite`
<FromGitter> <Blacksmoke16> where you running `shards install`?
<FromGitter> <sardaukar> just `shards`
<FromGitter> <Blacksmoke16> that prob defaults to install
<FromGitter> <Blacksmoke16> which uses the lock file
<FromGitter> <sardaukar> having to remove the lock file sounds off
<FromGitter> <Blacksmoke16> or just run `shards update`
<FromGitter> <sardaukar> `shards update` works
<FromGitter> <sardaukar> no need to remove the lockfile
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <sardaukar> one thing: I'm not sure what the behavior of `group_by` should be
<FromGitter> <sardaukar> or if I'm effing it up somehow
<FromGitter> <sardaukar> but that passing spec is very weird
<FromGitter> <Blacksmoke16> add a `pp result` and see what the output is
<FromGitter> <Blacksmoke16> or within your code where you want to use it
<FromGitter> <sardaukar> `pp result` -> https://github.com/amberframework/granite/pull/392/files
<FromGitter> <Blacksmoke16> hm, yea thats not right
<FromGitter> <Blacksmoke16> well maybe
<FromGitter> <sardaukar> I don't see it grouped. Maybe I messed up the delegation?
<FromGitter> <Blacksmoke16> do remember this is `SQL` `group by`
<FromGitter> <Blacksmoke16> not like crystal array `group_by`
<FromGitter> <sardaukar> Oh ok. Not super useful, then
<FromGitter> <Blacksmoke16> what output were you expecting?
<FromGitter> <sardaukar> Ideally, a hash with the groups as keys and the members of the groups as values inside an array
<FromGitter> <sardaukar> In the specific case of the spec, a hash with "Some Name" and "Some Other Name" as keys and their values arrays of 2 items and 1 item respectively
<FromGitter> <sardaukar> I'll have to do a DISTINCT on the `name` column and then do multiple queries with each value
<FromGitter> <Blacksmoke16> is that something you can do in SQL?
<FromGitter> <Blacksmoke16> i dont really think so, you probably would need to fetch all records and use https://crystal-lang.org/api/master/Enumerable.html#group_by(&block:T-%3EU)forallU-instance-method
<FromGitter> <sardaukar> I see granite is just a very thin layer on top of SQL, then
<FromGitter> <Blacksmoke16> right, thats what an ORM is :p
<FromGitter> <sardaukar> depends how thin :D Rails does this
<FromGitter> <Blacksmoke16> right, thats on `Enumerable` as well
<FromGitter> <Blacksmoke16> `latest_transcripts` is just returning an array of like `Transcript`
<FromGitter> <sardaukar> yeah, calling #day on each of them
<FromGitter> <sardaukar> not sure how useful my PR is now. Feel free to close it, if you'd like. I think I'll work a little bit outside of Granite to get what I'm aiming for on my project
<FromGitter> <Blacksmoke16> I mean you could just do like `Model.all.group_by(&.name) { |name, objects| ... }`
<FromGitter> <Blacksmoke16> or replace `all` with some query if you want to filter the collection
<FromGitter> <Blacksmoke16> `Model.where(:expires_at, :gt, Time.utc).select.group_by ...`
<FromGitter> <sardaukar> yeah, will have to be something like that
<FromGitter> <Blacksmoke16> an ORM just makes it so you can worth with objects and methods and now raw SQL
<FromGitter> <sardaukar> yep yep
<FromGitter> <sam0x17> best way to get client IP address in controller method?
<FromGitter> <sam0x17> there is also `client_ip` apparently
<FromGitter> <sam0x17> though it doesn't seem to work running `amber watch` locally -- maybe will work when behind an nginx proxy
<FromGitter> <sam0x17> trying this out: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e94f72ef87c5956a257ef8c]
<FromGitter> <sam0x17> 1) ensure not rescue
<FromGitter> <sam0x17> actually both rescue and ensure xD
<FromGitter> <sam0x17> for it to have a not nil return signature
<FromGitter> <sam0x17> there fixed:
<FromGitter> <sam0x17> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e94f7add021c45cc7e3c849]
<FromGitter> <Blacksmoke16> `client_ip.not_nil!.address.to_s if client_ip && client_ip.not_nil!.address` 😬