DEV Community

Debashish Palit
Debashish Palit

Posted on

Completed the app. About to deploy.

I completed the coding of my Blogfinder app! The past few days I worked on -

  1. Profile and home pages
  2. User follow and like features
  3. Managing of posts
  4. Testing

Some issues I faced were -

  • Post publish dates - I used moment to get a relative date from a timestamp (number of seconds). The peculiar thing that I noticed when working with Docker containers was that, by default, the timezone was UTC. This was causing the Python datetime module's timestamp function to give a wrong value for naive datetimes. I first thought it was a bug in Python. StackOverflow pointed out that docker was the problem and I had to add the following to the docker-compose file:
volumes:
  - /etc/localtime:/etc/localtime
Enter fullscreen mode Exit fullscreen mode

This worked but then I decided on another approach. That was to use aware-datetimes with the following code:

post.published = post.published.astimezone(timezone.utc)
Enter fullscreen mode Exit fullscreen mode
  • N+1 problem - I have a Post, a UserProfile and a User table. When there are many posts to get, the number of database queries to get the username from the User table and the fullname from the UserProfile table will be high. I chose to defer the queries to when there will be a few posts to serve (after pagination).

For testing, I created a number of dummy users with real personal blogs. I plan on creating similar dummy data on the deployed demo app as well. I hope the blog owners won't mind!

Tomorrow I will perform another round of testing and then deploy the app. After that, I will make the final submission post.

Top comments (0)