Part 1

This week was definitely more productive than last. I wrote out 3 endpoints, merged some fixes from upstream, and reworked our dev environment a bit. I ran into some issues getting the dev environment reworked since I was using an sql query to clear the tables that wasn't supported in sqlite so I had to set up some conditionals to handle migrations differently based on whether we were in a dev environment or production. When merging I also ran into a small issue due to there being a small typo throughout the code that was fixed upstream. That typo was also in the schema which caused some temporary issues that were easily fixed by rerunning the migrations though figuring out that that was the problem took some time. Though in the end I got it all working.
Ticket 1. https://github.com/Lambda-School-Labs/labs10-cleaner-tool/pull/9 https://trello.com/c/Qc56dgah Ticket 2. https://github.com/Lambda-School-Labs/labs10-cleaner-tool/pull/11 This one didn't really have a trello card. But it was needed. Ticket 3. https://github.com/Lambda-School-Labs/labs10-cleaner-tool/pull/15 https://trello.com/c/HzTZmS3R Ticket 4. https://github.com/Lambda-School-Labs/labs10-cleaner-tool/pull/18 This also didn't have a trello card but it included some fixes that I thought would be helpful to the team.
I'm going to go into more detaul about pull 15. This is where I implemented getting surveys by ID and just getting all surveys at once. I implemented it using a method I found Here I quite liked the idea of breaking down the queries to very small and reusable functions that could then be chained together to build out queries without having to worry about the specific implementation. For example I have this nice little tiny function.
That acts as the base for all of the rest of my queries which makes it very easy to just change which table I want to be working on at any given time by changing just the single function which should then cascade down to the rest of the functions. This litte bugger actually gave me quite the headache. Originally he was just.
I probably spent a good hour trying to figure out the problem I was having where it just kept adding to the query instead of creating a new one each time it was ran. In the end I figured out that I needed to wrap it in a function to stop that.
All I have to do to use this is pass it a field and the value I want and it should return a QueryBuilder that has been filtered on that field by the value that I pass to it. I then have this function.
Then I tie it all nicely together with this final function to return a single survey. It's quite an elegent solution and I see myself definitely using this in the future in such a small example it is a bit overkill but for larger queries I could see this being extrmely useful.