Add trendiness function relying on postgresql