This is the bug tracker for Photo Organizer.
FS#180 - Break out the statistics data
Attached to Project:
Photo Organizer
Opened by Solomon Peachy (pizza) - Tuesday, 06 March 2007, 10:25 GMT-4
Last edited by Solomon Peachy (pizza) - Sunday, 06 January 2008, 11:03 GMT-4
Opened by Solomon Peachy (pizza) - Tuesday, 06 March 2007, 10:25 GMT-4
Last edited by Solomon Peachy (pizza) - Sunday, 06 January 2008, 11:03 GMT-4
|
Detailsright now "view counts" are part of the "photo" table.
It might be beneficial to split stats to a separate table.. we can track additional fields (views vs downloads vs ??) and also track it for each photo version etc. |
This task depends upon
views_per_photo(photo_id) -- SELECT sum(f.views) FROM files f, photo_version v WHERE v.identifier = f.version AND f.size != 1;
views_per_version(photo_id, version_id) -- SELECT sum(f.views) FROM files f WHERE f.version = version_id AND f.size != 1;
The migration will assign all existing views to the 'preview' image of the primary version, and will probably need to be an PHP function.
UPDATE files SET views = (select p.views from photo p, photo_version v WHERE p.identifier = v.photo AND files.version = v.identifier) WHERE size = 2;
Question -- what do we do when we delete a version or file with X views? (Does this mean we need to maintain a global per-photo 'other views' counter that factors in?)
I'm probably missing something obvious here, but what's wrong with subtracting the version/file's views_per_version from the views_per_photo before deleting?
That is, if it needs subtracting at all... Since those views all count towards a photo, regardless of the current status of any additional versions, shouldn't they remain?
So, this would logically mean:
1) per-file counter incremented on each 'hit'
2) per-version counter incremented on each 'hit'
3) per-photo counter incremented on each 'hit'
4) querying views_per_X is trivial; just look up the value in the right table.
or:
1) per-file counter incremented on each hit
2) when file is deleted, per-version counter += file counter
3) when version is deleted, per-photo counter += file counter
4) to query views_per_X, one has to take the value in table X and add the values for its "children" too.
Normally there are more hits than views_per_X, so the first model is slower on a busy site -- but it's also much simpler to code. The second model scales far better, but is more complex programically and views_per_X is ovbiously more complex to compute.
(Note that all of the lifting can be hidden inside triggers & stored procedures, so from the UI's perspective, there's no difference)