Reno, NV    +1 (800)0 621-0871

Go back

Internship

Growing Stuff at ÆLOGICA

  |  July 30, 2015

growstuff

From the first day of ÆLOGICA’s internship program, we were asked to find an open source project to where we could contribute to. After few days, I found Growstuff which is an open source platform for food gardeners’ community.

I did some runs on Rails console in order to do some simple tests and familiarize myself on Growstuff, specifically on how to access the database and get data from each table with all their relations. I then proceeded on doing the calculations.

Calculations

The first step is generating a Rails migration which adds a ‘days_before_maturity’ column on the plantings table which will be the primary basis for calculation. I created a private method on the plantings controller which automatically fills up or updates the ‘days_before_maturity’ attribute upon creation or update of a planting. Finding the remaining days before maturity for a planting is very straightforward if the start and finish date is provided by the user. Otherwise, a mildly complex calculation needs to be done.

To get the average days before maturity of the planting for a specific crop, I collected all the previous plantings with the crop of the same type on the database excluding itself and other uncertain data sources. Uncertain data sources refers to plantings where the days before maturity is unknown, plantings where a specific finished date is not specified, or plantings marked as finished regardless of the specified finished date. After collecting all the valid plantings, I got their average days before maturity and inserted it as the attribute of the instance being created or updated. After that, I made the progress bars represent the progress or state of a planting by finding the difference of the current time and the starting time, over the days before maturity attribute in percentage. With that, I was able to know the state which identifies if progress bars should be red- when progress is unknown, orange- when planting is not planted yet, or green- when planting is in progress.

Testing

I started testing with Capybra. I had difficulty with testing this feature since it involves getting the current date which is dynamic, contrary to the test cases wherein the results are predefined and static. I eventually managed a way to work around this by stubbing ‘DateTime.now’.

growstuff

During this summer, I learned about Ruby, Rails, testing with Rspec and Capybara, and TDD. The objective of the internship program was achieved with the help of the supportive environment provided by ÆLOGICA. Thanks to them, I found a new hobby of contributing to the open source community.