nickyhajal / world-domination-summit

Code for the World Domination Summit
http://worlddominationsummit.com
3 stars 5 forks source link

Decay Old Screen Content in Favor of New Content #66

Closed nickyhajal closed 10 years ago

nickyhajal commented 10 years ago

The screen system I built in the past favored newer flickr photos + tweets over old ones which makes the system feel more lively and exciting.

I did this in the past with an ageContent function that could be run on a contentType and would basically add more instances of that content item in the array of content based on how new it was (24 - hours alive)

Here's the function:

sc.ageContent = (type, inclusive = false) ->
    temp = []
    for cont in sc.contentByType[type]
        now = (+new Date()) / 1000
        stamp = (new Date(cont.stamp).getTime()) / 1000
        factor = Math.floor(24 - ((now - stamp) / 60 / 60))
        if factor > 0
            for i in [0..factor]
                temp.push cont
        else if inclusive
            temp.push cont
    sc.contentByType[type] = temp

It would probably need to some tweaks to work with our current system but the general idea should still work (of course, feel free to do it however seems right to you).