<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?
<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)