DEV Community

Discussion on: What's the worst code you've ever written?

Collapse
 
onlyphantom profile image
Samuel Chan

Boss: Try to track page views on our website, but also try to avoid making a database trip on every single page load.

Me: Say no more.

from random import randint
if randint(0,16) == 16:
  model.view_count += 16
  model.save()
Enter fullscreen mode Exit fullscreen mode