Ever wondered how you can sort records by a popularity metric, but add a time discount? (e.g. newer records rank higher)

I asked #gptchat and it came up with this formula:

ORDER BY upvotes_count * POW(0.998, extract(day FROM CURRENT_DATE - startups.featured_at)) DESC
It takes a popularity metric (in this case upvotes_count) and multiplies it by a time-discount multiplier.

The longer ago a startup was featured, the lower this number.

Here's how it works:
It calculates the days since the startup was featured:

extract(day FROM CURRENT_DATE - startups.featured_at)

For example, this might return 60 for a startup featured two months ago
It then uses the POW() function to turn it into 0.998⁶⁰ which equals about 0.89

This is used to discount the upvotes_count:

100 upvotes become × 0.89 = 89 "discounted" upvotes
The longer ago a startup was featured, the lower this multiplier will be.

These are all ranked about the same:

Featured today with 89 upvotes
Featured 2 months ago with 100 upvotes
Featured year ago with 185 upvotes
Where does the magic 0.998 number from?

I made it up. It's what determines how much time discounting you want to do.

I came to 0.998 by trial and error. I ran a bunch of queries and noticed that with 0.998 it discounts startups featured a year ago by about 50%.
I wanted to priortize newer startups over older startups. But you can also do the reverse.

If you multiply by a positive number like 1.01ʸ then recent records will rank lower versus older records with the same amount of upvotes.
Give it a try. Curious what you come up with :)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with marckohlbrugge.eth

marckohlbrugge.eth Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @marckohlbrugge

Nov 13
Yesterday, betalist.com got DDoS'd. The attacker posed as a "security researcher" asking $5,000 in Bitcoin to "solve" the issue 😂

Today, a WIP member got his site attacked as well.

They might be targeting indie makers so make sure you're prepared.
Fortunately blocking the bot traffic is relatively straight forward.

Make sure you're using a firewall like Cloudflare, and don't expose your server IP address anywhere. (or else they can cirmcumvent Cloudflare)
When you get attacked, Cloudflare will automatically block some of the bots. But probably not all.

You'll want to enable "Under Attack" mode. And confgure your firewall rules to be a bit more aggressive.
Read 5 tweets
Sep 15
🚀 Launching my newest product: IMAGE.COMPUTER

It's a super simple way to generate images with AI.

No need to install any complicated tools or make your computer fans run overtime. Let us do the work for you 😄

Free 25 credits today: IMAGE.COMPUTER
Why did I make this?

Last week I was trying to help a friend set up Stable Diffusion (tool to generate AI images) on her new MacBook Air M2. It was a very complicated process and when we finally finished it, it took about 20 minutes to generate a simple image🤨
I challenged myself to build a simple web app she could use instead. We got a food delivery scheduled to arrive in about 45 minutes, so that's the time I gave myself to finish the first prototype.

Just after I deployed it, the doorbell rang and the food arrived! 😅
Read 8 tweets
Jul 4
Last couple of weeks I've been migrating WIP.co to use Tailwind CSS and Rails ViewComponent. It was a lot of work, but it really paid off.

I feel like I can ship user-facing features much faster now. Some things I shipped the last couple of days… Image
Easily share todos with native sharing functionality (also works on mobile)
See which other makers liked your todos Image
Read 11 tweets
Jun 24, 2021
I maintain 10+ websites. My four tips for keeping track of it all as a solo-founder:

♻️ Re-use same architecture across all products

🔔 Set up notifications for when things break

💬 Make it easy for customers to reach me

❌ Don't rely on dashboards. I'll forget to check them
♻️ 𝗦𝗮𝗺𝗲 𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸

For me that means Ruby on Rails. It doesn't really matter what you use, as long as you're consistent.

This means any insights you get along the way (e.g. how to upgrade to new version) can be easily applied across all your apps.
♻️ 𝗦𝗮𝗺𝗲 𝘄𝗲𝗯𝗵𝗼𝘀𝘁

I'm in process of moving all my apps to @render because they strike the right balance between flexibility and affordability.

Some smaller apps were cheaper on my own VPS, but I prefer having the same architecture everywhere.

render.com
Read 12 tweets
Jun 22, 2021
Me and @RPISH have taken a more pro-active sales approach for @BetaList the last 12 months.

Result: +50% annual revenue 📈👀

Not bad for a 10+ year old product :)
@RPISH @BetaList Biggest change was a mindset shift from passively responding to inquiries ("here are our rates, kthxbye") to truly trying to understand a customer's goals and how we can help achieve them ("what's your goal here? what would a successful campaign look like?" etc)
Major shout out to @louisnicholls_ for his salesforfounders.com course which helped cement this paradigm shift.
Read 4 tweets
Apr 12, 2021
I've been migrating my web apps (15 and counting…) from Heroku and Linode to Render.com

So far I really like it. It shares a similar philosophy to Heroku (outsource your devops), but more affordable and actively developed.

Worth a try 👍
My favorite feature is "code-as-infrastructure" which leads you lay out your whole stack in a single YAML file. Not a new concept, but I like their simple approach. Image
lets*
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(