mediagoblin-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GMG-Devel] Plugin for page view counter


From: Christopher Allan Webber
Subject: Re: [GMG-Devel] Plugin for page view counter
Date: Mon, 07 Jan 2013 17:35:44 -0600
User-agent: mu4e 0.9.9-dev6; emacs 24.0.92.1

Tiberiu C. Turbureanu writes:

> Hello,
>
> I am new to both Python and MediaGoblin, but I've just setup an instance 
> on my organization server and I'm thrilled of what it can do already! I 
> also supported the project through a donation last year during the 
> campaign, because I believe in the importance of this Free Software 
> project to fill a gap in the online video distribution.
>
> I would like to start contributing by writing a plugin that counts the 
> number of views, something basic, not the full stats functionality 
> Youtube has. But it would be really nice at least for my organization to 
> have this simple success metric available.

Awesome!  Yes, this is a feature we would love to have.

> I read the docs.mg.org and wiki.mg.org related to plugin development and 
> I believe I can write this plugin. But I would need a little bit of 
> mentoring. I am also available on the IRC channel #mediagoblin (nick: tct).

Great!

There are several people in the channel who are likely to be able to be
helpful, and now that I'm fulltime on mediagoblin work, I should be able
to be as well, if you need guidance.

> I am thinking that this plugin could add a new table to the gmg database 
> and be 1-1 with the core__mediafiles. I don't like the idea to alter the 
> core table for reasons related to upstream development and stability.

Yes, a plugin should not be altering core tables.  We have a mechanism
for adding new tables as you described.

> This new table would have two columns: the id of the media file and the 
> counter, by default set to zero. Then all the plugin would have to do 
> everytime a media file page is loaded is to read the counter from the 
> table, increment it and store it back in the table.
> 
> I know that there can be data races when a media file is played by 
> multiple users. I am happy to hear from you if Python has some atomic 
> increment for its storage abstraction.


We're using SQLAlchemy, and through that you should be able to make use
of the underlying sql incrementing tools.  There's some useful data
here:

http://stackoverflow.com/questions/2334824/how-to-increase-a-counter-in-sqlalchemy

>
> Or if you see another approach for the data race problem, like keeping 
> view counters for concurrent accesses in memory and writing it back to 
> the data base when the media file is not played anymore. But this would 
> not scale for many concurrent users on a service with a large collection 
> of media files.

I think the above as linked would work fine.  The main worry would be
if it were too write-heavy, but probably that's not something we need to
worry about initially.

> Or maybe you have other ideas. Anyway, I will appreciate any help. Thank 
> you in advance!

Great... I look forward to discussing this more! :)
 - Chris


reply via email to

[Prev in Thread] Current Thread [Next in Thread]