Help | About | Suggestions | Alms | Chat [0] | Users [0] | Log In | Join
 Search:
Poem: Submit | Random | Best | Worst | Recent | Comments   

Suggestion:
Bluemonkey @ 170.141.68.99 | 20-Jan-05/11:05 AM | Reply
What if you added a best of the month or best of the last three months or something.

Replies:
nentwined @ 64.60.192.130 | 20-Jan-05/11:13 AM | Reply
That's... difficult, if you mean "by votes placed in the last month or three months". There's 10,000 poems, and it's a slow operation to actually calculate a poem's average; at least in "internet time". At least, I don't know of a better way than what I'm doing, and that takes about (runs "explain analyze") 7.5 seconds to get the "current average" of every poem. What I do to get around that is keep the running tally on the poem itself and update that when either the poem is edited or someone votes on it.

SELECT id, voteaverage(id) FROM poemranker_poems: 7483.31 msec
SELECT id, avg FROM poemranker_poems: 190.28 msec
nentwined @ 64.60.192.130 > nentwined | 20-Jan-05/11:14 AM | Reply
create or replace function voteaverage(int4) returns float as '
DECLARE
myavg float8;
BEGIN
myavg = 5+(float8(((avg(v.value)-5)))*(1/(1+exp(float8(3-count(v.value)/3))))) from votes v, poemranker_poems p WHERE v.poemid = $1 and v.poemid = p.id AND v.stamp > p.lastmod;
if myavg IS NULL THEN
return 5;
end if;
return myavg;
END;
' language 'plpgsql';




Track and Plan your submissions ; Read some Comics ; Get Paid for your Poetry
PoemRanker Copyright © 2001 - 2025 - kaolin fire - All Rights Reserved
All poems Copyright © their respective authors
An internet tradition since June 9, 2001