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
pedrosanta has joined #amber
pedrosanta has left #amber ["cool"]
pedrosanta has joined #amber
pedrosanta has left #amber [#amber]
_whitelogger_ has joined #amber
_whitelogger has quit [Remote host closed the connection]
_whitelogger has joined #amber
feepbot has quit [Ping timeout: 258 seconds]
feepbot has joined #amber
<FromGitter> <charleystran> are there any special restrictions to getting the size of an array? I have an array with 36k items and when I call size on it I only get 36
<FromGitter> <Blacksmoke16> mmm array of what?
<FromGitter> <Blacksmoke16> im thinking you just dont have 36k items in your array
<FromGitter> <charleystran> database records, i dont think its actually any array, but whatever the results set is. I am writing them all to a CSV for some machine learning tasks. Everything loops and iterated just fine, but thee `.size` is off
<FromGitter> <Blacksmoke16> what if you do `.to_a.size`?
<FromGitter> <Blacksmoke16> might be a Granite collection if you're fetching it via `.all`
<FromGitter> <charleystran> ill try that
<FromGitter> <charleystran> that gives me `in sam.cr:31: undefined method 'to_a' for Granite::Query::Builder(Race)`
<FromGitter> <Blacksmoke16> oh so you have a query builder
<FromGitter> <Blacksmoke16> just do a `.select` at the end
<FromGitter> <charleystran> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d03a731bc56c731f8b967c3]
<FromGitter> <Blacksmoke16> its lazily loaded
<FromGitter> <Blacksmoke16> the `.each` actually executes the query which is why that works
<FromGitter> <Blacksmoke16> but calling `.size` on `entries` before the loop isnt the actual array of results
<FromGitter> <charleystran> its size on `races` in the loop
<FromGitter> <charleystran> ill try it
<FromGitter> <charleystran> yea, that works!
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <charleystran> thanks
<FromGitter> <Blacksmoke16> prob could also use `.each_with_index` instead of a counter?
<FromGitter> <charleystran> yea, I probably should
<pracabor> @charleystran you can/should also use a dedicated sql-based count instead of reading the entire dataset just to get a count
<FromGitter> <charleystran> @pracabor, I actually started that way and got the same result, but didnt know I needed to call select on it first
<pracabor> can you post your code?
<FromGitter> <charleystran> I have it all working now thanks to @Blacksmoke16
<pracabor> oh, great
<FromGitter> <charleystran> still pretty new to crystal and learning its edges and corners
vivus has joined #amber