Twitter Search – Day 15 MVP

Day 15 Add Search History (see project overview)

Today, I’m going to add a bit to the Researcher model, then start with the deploy.  

My AWS is no longer mostly free 🙁

I’m going to go ahead and use the AWS account I’ve been using, which is past its free period.  I think I can just see how much this will cost and shut it down if need be.  I prefer to do things on the up and up, but some costs are so high, it feels like I’m being robbed.  Feeling the same way about Twitter data so I am limiting the number of requests that can be made by a button click in my app to 1.  If not for my deliberate limitation, one query could use up all my requests.  I could also take out the while loop that checks the next field in the data returned from Twitter, but that seems wrong.  I could also do a counts query and ask the user if they really want all that data. For now, I’m leaving it.

Should migrations be in your repro?

To support search history, some database changes are needed.  This got me into the “should we add migrations to .gitignore” rabbit hole.  I think the consensus (and Django docs advice) is that migrations should be kept in the repository.  Maybe, it’s overkill to keep them before you have a teammate or a production environment, but I’m keeping them, anyway.

Just write the gosh danged tests!

I added the Researcher and Search (history) models.  I am writing a history record for each request to Twitter.  I made quite a few changes to accomplish this, so I thought I should run my tests again.  The tests, even though they are pretty dang simple, have helped me find some problems…such as not allowing null in the Search from and to dates.  The Twitter request doesn’t require from and to dates.  If you leave them out, it will default to the current month.  So, the Search history needs to allow dates to be null.  The tests have taken a bit of extra time, but, as advertised, they actually save time.

In the .Net code I’ve written over the past couple years, I always use tests.  Mostly, I use them to test classes before I’ve written the class consumers.  But, I’ve not written tests for the Python code I’ve written in the past two years because it wasn’t something we, as a team, had committed to do.  I should have helped my team by writing tests for all of my work whether or not it was a team standard.  Sorry team!

If tests can help you find something so basic as “my model is wrong”, then I’m a fan!  I’m ashamed to say that I’ve made this same exact error in production applications (only one, really).

It’s MVP!

Now the app has the ability to limit the number of requests a person makes and it will show previous requests.  I need to add a test for the view function that returns whether or not the person has more tweets available, then, on to deploy details.  

I know there is more that could be done, but it’s MVP, so I’m deploying.

Leave a Reply

Your email address will not be published. Required fields are marked *

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Consent to display content from Youtube
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound