Photo Organizer

This is the bug tracker for Photo Organizer.
Tasklist

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
Task Type Feature Request
Category Backend / Core → Database
Status New
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version 2.33
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

right 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

Comment by Solomon Peachy (pizza) - Wednesday, 25 April 2007, 22:47 GMT-4
Perhaps it should be moved into the 'files' table; this way we can keep track of all image sizes independently.
Comment by Solomon Peachy (pizza) - Tuesday, 24 July 2007, 08:55 GMT-4
Or... eliminate it entirely, and use the logs to infer it.
Comment by Solomon Peachy (pizza) - Friday, 19 October 2007, 12:24 GMT-4
Views needs to be associated with the file records. We can create functions to obtain the views_per_photo, views_per_version figures. They'll include everything but the thumbnail.

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?)
Comment by Rickard Olsson (Richie) - Sunday, 17 February 2008, 14:42 GMT-4
> what do we do when we delete a version or file with X views

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?
Comment by Solomon Peachy (pizza) - Monday, 18 February 2008, 11:23 GMT-4
The original idea was that we'd eliminate the top-level views altogether.. but instead, it would seem we need to retain it, and update the top-level count on-the-fly or when things are deleted.

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)
Comment by Solomon Peachy (pizza) - Monday, 18 February 2008, 11:33 GMT-4
oh -- and we don't want the per-photo/version statiscs updated for thumbnails, just to complicate things.

Loading...