DEV Community

Cover image for Templates and Logic - Building SaaS #45
Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

1

Templates and Logic - Building SaaS #45

In this episode, we added content to a template and talked about the N+1 query bug. I also worked tricky logic involving date handling.

The first change was to update a course page to include a new icon for any course task that should be graded. After adding this, we hit an N+1 query bug, which is a performance bug that happens when code queries a database in a loop. We talked about why this happens and how to fix it.

After finishing that issue, we switched gears and worked on a tricky logic bug. I need a daily view to fetch data and factor in the relative time shift between the selected day and today. We wrote an involved test to simulate the right conditions and then fixed the code to handle the date shift properly.

This article first appeared on mattlayman.com.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay