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> <drujensen> @sardaukar one option for your group by is to specify your own select and them map the columns to the expected results. As @Blacksmoke16 stated, it’s a simple mapping to a sql resultset. That way instead of an array of gashes, you get an array of objects.
<FromGitter> <elorest> @Brodan The VHU (Vehicle Head Unit) communicates with the rest of the truck using CAN and other protocols. Messages aren't in JSON, XML or text at all. Instead they're using raw binary. In CAN you can figure out what they mean by reading a DBC file. This will tell you that for Packet A1 from Controller A the first bit represents the status of the headlights (off/on), the next 3 bits represent transmission values form
<FromGitter> ... 0-7, the next 12 bits represent your speed in KPH. ⏎ ⏎ What I was referring to above was a protocol to communicate over UART with a low level controller. It sends it's data by adding it to a packed struct, dumping the bytes, compressing, numbering, signing, and writing them to the socket. It's also sending many di ... [https://gitter.im/amberframework/amber?at=5e953743e7ca460b065b9205]
<FromGitter> <Brodan> @elorest sounds awesome. Thanks for the explanation! I don't understand most of it as I've never done any work with microcontrollers but it sounds pretty awesome.
<FromGitter> <sam0x17> in granite -- how to call `to_a` or the equivalent on a where chain (I just want to get the first item in this case) without doing something silly with an iterator
<FromGitter> <sam0x17> current hack I'm using is `Model.where.chain.limit(1).map { |item| item }.first`
<FromGitter> <damianham> Model.first("where...")
<FromGitter> <damianham> or is it Model.all("where...").first - I work with 3 or more languages and frameworks simultaneously so I always have to keep checking :)
<FromGitter> <sam0x17> one would think it would just be .first, but that' s undefined in granite
<FromGitter> <sam0x17> so is .to_a
<FromGitter> <sam0x17> so is [0]
<FromGitter> <sam0x17> it's a bit maddening
<FromGitter> <drujensen> The where method returns an object. To execute the query, there are a handful of methods that trigger it. Map is one of them. I recommend using select to execute the query and get the array. Then you can use first, [0] or any enumerable method on the array.
<FromGitter> <drujensen> Would be nice if the where returned an object that supports enumerable
<FromGitter> <sam0x17> so just .select on the end of the chain?
<FromGitter> <damianham> I was right first time ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e95cf9bcc370f0b07e48590]
<FromGitter> <sam0x17> ah so its like, the first thing in the chain not the last?
<FromGitter> <sam0x17> wish that was documented in querying if so
<FromGitter> <sam0x17> when I try throwing a .first to the end of a chain I get undefined method
<FromGitter> <sam0x17> also I'm planning to add aggregate methods if anyone has any thoughts https://github.com/amberframework/granite/issues/393
<robacarp> @sam0x17 - neat
<robacarp> I'm skeptical that the methods would be uniform enough to be implemented as macros, but if it works
<robacarp> I also don't think it's unreasonable to implement a .first method in the query builder (I'm surprised it hasn't been done already?) so that it'll just run a limit(1) and return a single T instead of Array(T)
<robacarp> man, that code is probably already working, it just needs to be uncommented https://github.com/amberframework/granite/blob/master/src/granite/query/assemblers/base.cr#L146
<FromGitter> <sam0x17> btw I updated the monkey patch snippet just now -- there were some errors but now it is correct
<FromGitter> <sam0x17> the macro has a different signature now as well, and yeah it was a lot easier then a bunch of almost duplicate code
<FromGitter> <faustinoaq> Hi Amber community! I just updated Amber AUR to version 0.34.0 https://aur.archlinux.org/packages/amber/
<FromGitter> <faustinoaq> Feel free to report any issue
<FromGitter> <drujensen> Thanks @faustinoaq