Hacker News new | past | comments | ask | show | jobs | submit login

    You can also design more complex boosters, for example, boost by the rating, 
    but only if the ranking has a certain number of votes. To do this, you can 
    create a function like this:

    create function numericBooster(rating numeric, votes numeric, voteThreshold numeric)
 returns numeric as $$
  select case when votes < voteThreshold then 0 else rating end;
    $$ language sql;
There's really no need to use a function here. It does nothing and makes the code at the call site harder to understand. Additionally, using a function might incur unintended performance penalities. At the very least, the function should be marked IMMUTABLE LEAKPROOF PARALLEL SAFE.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: