2 ms·
Um, very. 25 columns? Just record each commentid and vote like so: create table vote_history ( commentid int, ts int primary_key (comme
by aristus 18y ago
Um, very. 25 columns?
Just record each commentid and vote like so:
create table vote_history (
commentid int,
ts int
primary_key (commentid, ts)
);
Where ts is a unix timestamp. Now you can get rankings for any time slice:
select commentid, count(commentid) as points from leaderboard where ts > <TIMESTAMP> group by commentid order by points desc;
That gives you to-the-second resolution, which is probably overkill. So instead you can try this:
create table votes_per_hour (
commentid int,
hourid int,
score smallint,
primary_key (commentid, hourid)
);
Where the value of hourid is the unix timestamp divided by 3600.
- deleted 18y ago[deleted]
- jmtame 18y agothanks =] sometimes my mind jumps to the worst solution first, not sure why. after you look at something like that, it's sort of a "wow.. duh.." moment.