Wednesday, July 2, 2008

exg anew

Started with exg - the 'thing' that drives {ego}trips on my website - once again, after almost an year. I was skeptical about getting a hold of the code again, but that wasn't much of a problem. I can easily understand my retard coding practices anytime.

I wished to make some changes, which I started to pen down (and simultaneously work upon a solution).
Change #1 was to put a 'latest uploaded galleries' listing on the homepage. Quite simple, isn't it? But again, generating relative rankings was a bit of a problem. There didn't seem any way that SQL would work. Ideal way to tackle it would've been through complex queries, but I chose to put PHP to use to do so.

That led me to discover some serious flaws in my earlier scripts, which notably had to do with relative ranking of image galleries (with respect to trips) and the consequent changes on enabling/disabling them. Not only did it lead to some errors but also exposed private galleries.

Then I came to realise that there was some problem in the clan page as well. Private galleries were also visible through the generated links. Fixed that as well.

By the end, my sheet was littered with headings:
Task
-Problem
--Problem
---Bigger Problem
----Added Problem
-Another Problem
--Existing Problem
-Still a Problem

Ended up jumping between code for about 3 hours. Quite a sudden change in my daily routine of idleness. Here's a small query to pull some stuff from the database. BEAT THAT!

select * from
(select @rn := @rn + 1 as rank, ptjoin.*
FROM (SELECT pm.perspective_id, pm.trip_id, t.trip_title, pm.title,pm.member_id,pm.member_name
FROM (
SELECT p.perspective_id,p.trip_id,p.title,p.member_id,p.created,m.member_name
FROM perspective p
INNER JOIN members m
ON p.member_id=m.member_id
WHERE p.trip_id = XXXX
)as pm
INNER JOIN trip t
ON pm.trip_id=t.trip_id
ORDER BY pm.created
) as ptjoin
) as rankedptjoin
where rankedptjoin.rank = XXXX;


Now I'll start with building the feature to upload docs for the trips, anything that helps.

No comments: