Nuts and Bolts
Posted: May 17th, 2012, 9:00 pm
I'm creating this topic for the discussion of the stuff that goes on behind the scenes, to keep it from clogging up normal discussions. I hope to be able to pick the brains of our benevolent developers. If any of them wish to tidy up the other forum topics that have posts that have this level of discussion, feel free to dump them in here.
WARNING!
Geek alert from this point forward!
Another question or two, because I'd like to understand how a website like this operates behind the scenes. Are the webpages static HTML generated en masse with each update (hope not), or generated on demand from a set of template pages which use, e.g., PHP fields passed through the URL to query the database? Looks like you have the point totals pre-computed and stored in tables, probably with the heavy crunching performed offline then pushed to the server, is that right? It would be cool if the Live API data were fed directly into your live database, and all the supporting queries update with new data as it comes in. But I imagine that would be difficult to keep from breaking and might be "unfair" because of the round-robin way the Pocket Queries bring in data, and would likely bog down the server enormously. Just displaying this Top 10 rankings would require that every cache's points be recomputed, LCP-wide, and every cacher's total hide and find scores be summed -- looks like you're taking the sane route of doing those computations off-line.
WARNING!
So, because I noticed, I have to ask: Why the one letter source tables/queries names? "r", "g", "s", "p"? Or is this some syntax with which I am unfamiliar?Corfman Clan wrote: here's the SQL query for the above pic, another small glimpse into the LonelyCache database schema:![]()
Code: Select all
SELECT Row,Ranking,CacherID,Cacher,Total ,(select sum(OverallPoints)from GeocacherPoints Where CacherID=r.CacherID and job=1 and RegionID = 1) FindsTotal ,(select sum(OverallPoints)from GeocacherPoints Where CacherID=r.CacherID and job=2 and RegionID = 1) HidesTotal FROM (SELECT ROW_NUMBER() OVER (ORDER BY Total DESC, g.Name) AS Row ,RANK() OVER (ORDER BY Total DESC) AS Ranking ,CacherID, g.Name as Cacher, Total FROM (SELECT CacherID, SUM(g.OverallPoints) AS Total FROM dbo.GeocacherPoints g WHERE regionid = 1 AND Job IN (1,2) GROUP BY CacherID) s JOIN dbo.Geocacher g ON g.ID = CacherID) r WHERE Row between 1 and 100 ORDER BY Row
Another question or two, because I'd like to understand how a website like this operates behind the scenes. Are the webpages static HTML generated en masse with each update (hope not), or generated on demand from a set of template pages which use, e.g., PHP fields passed through the URL to query the database? Looks like you have the point totals pre-computed and stored in tables, probably with the heavy crunching performed offline then pushed to the server, is that right? It would be cool if the Live API data were fed directly into your live database, and all the supporting queries update with new data as it comes in. But I imagine that would be difficult to keep from breaking and might be "unfair" because of the round-robin way the Pocket Queries bring in data, and would likely bog down the server enormously. Just displaying this Top 10 rankings would require that every cache's points be recomputed, LCP-wide, and every cacher's total hide and find scores be summed -- looks like you're taking the sane route of doing those computations off-line.