ariutta/data-engineering — pull request #1 by radar (2012-04-15 14:06:31+00:00)
Title: Hash improvemnets

Hey Anders,

it was nice to meet you too!

From your description of the code the other night, I thought you were just summing one column of the data. If you were doing that, then you would probably do this:

```ruby
revenue = upload_file.inject(0) do |row, total|
total += row['purchase count'].to_f * row['item price'].to_f
end
```

But since you're creating a number of other thing here, I think sticking with how you've done it is good.

---

In this patch I've separated out the key and value pairs in hashes with a space, as is the Ruby standard. If you were using the old hashrocket syntax, it would look something like `:foo => "bar"` rather than `:foo=>"bar"`. Spaces are free, so use them freely.

The second change I've done is made the line for `Purchase.create` go over two lines. The reason for this is because in the editor on my screen I needed to scroll horizontally to read what the code was doing. This shouldn't be necessary, and so splitting it out over multiple lines was the right thing to do in my mind.

Happy to help!