How does work view_count ?

Author Message

Pascal France

Tuesday 14 August 2007 12:29:11 pm

Hi,

I would like to display the number of time a node has been viewed using view_count.

After looking for in the ez.no's forums and documentation parts I did the following:

1°/ In my public siteaccess cronjob.ini.append.php file:

<?php /* #?ini charset="utf-8"?

[CronjobSettings]
Scripts[]=updateviewcount.php

*/ ?>

2°/ In my public siteaccess logfile.ini.append.php file:

<?php /* #?ini charset="utf-8"?

[AccessLogFileSettings]
StorageDir=/var/log/apache/
LogFileName=access.log
SitePrefix[]=luxpopuli
SitePrefix[]=luxpopuli_admin

*/ ?>

In this code I tried also to add an escaped slash at the end of the two last lines (according with this post: http://ez.no/community/forum/setup_design/how_to_get_the_popularity_of_a_node#msg119935)

3°/ In my article view template:

{$node.view_count}

4°/ I run the runcronjobs.php script:

php runcronjobs.php -c -d -s luxpopuli

Using siteaccess luxpopuli for cronjob
...
...
...
Running cronjobs/updateviewcount.php
Update content view count...
Started at Mardi 14 Août 2007 8:20:20 pm

Start line:
82.67.66.131 - - [14/Aug/2007:20:18:21 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://luxpopuli.fr/ez_publish__1/documentation_ez_publish/reference_reference/objects_objets/ezbinaryfile" "Opera/9.22 (X11; Linux i686; U; en)" "-"

Finished at Mardi 14 Août 2007 8:20:20 pm

View count have been updated!


########### DEBUG ##########
Notice: (eZMySQLDB::query(0.000 ms) query number per page:0)
SET NAMES 'utf8'
...
...
...
Timing: ()
Script cronjobs/updateviewcount.php starting

Timing: ()
Script cronjobs/updateviewcount.php done


Total script time: 1.4071 sec

5°/ I access some articles

6°/ I re-run runcronjobs.php... but the counters on the public pages stay set to 0

Another thing:

I can't fing a "view_count" field in any ezcotobjectxxxx tables. So, how does work the updateviewcount.php script ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Felipe Jaramillo

Tuesday 14 August 2007 3:28:38 pm

Hi Pascal!

It seems your config is correct.

I believe the view_count is a very simple implementation of the eZPersisanceObject and it stores it's data in the ezview_counter table.

Maybe you can check if the records are actually being updated. Also, checkout the cronjob file as it's structure is pretty simple on how it retrieves and updates the records.

My main issue with it is that the view_counts obviously favours the oldest items in your site. It would be great to extend this functionality to add stats of views today, this week, this month and this year in addition to general views.

Regards,

Felipe

Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia

Pascal France

Wednesday 15 August 2007 3:25:23 am

Hi Felipe,

My view_count table only contains these values:

count   node_id
   4           819

My questions are:

- why only this node ?
- why the count colum is not updated (after running the updateviewcount.php script) if I access the node_id 819 many times ?

For information, this is a typical reccord of my apache log:

15.11.130.178 - - [15/Aug/2007:11:48:26 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://www.luxpopuli.fr/ez_publish__1/configuration__1/apache_mod_deflate_et_mod_gzip" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" "-"

and this is the content of the var/plain_site/log/updateview.log file:

# Finished at Mercredi 15 Août 2007 12:14:59 pm
# Last updated entry:
82.67.66.131 - - [15/Aug/2007:12:10:45 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://luxpopuli.fr/ez_publish__1/trucs_astuces" "Opera/9.22 (X11; Linux i686; U; en)" "-"

Maybe there is something wrong or missing in my logfile.ini ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:32:31
Script start
Timing: Jan 18 2025 11:32:31
Module start 'layout'
Timing: Jan 18 2025 11:32:31
Module start 'content'
Timing: Jan 18 2025 11:32:32
Module end 'content'
Timing: Jan 18 2025 11:32:32
Script end

Main resources:

Total runtime1.0115 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 589.0313152.6250
Module start 'layout' 0.00600.0031 741.656339.4453
Module start 'content' 0.00911.0010 781.1016514.0859
Module end 'content' 1.01010.0014 1,295.187512.1641
Script end 1.0115  1,307.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3827160.0002
Check MTime0.00170.1666160.0001
Mysql Total
Database connection0.00100.099310.0010
Mysqli_queries0.953094.2200570.0167
Looping result0.00060.0570550.0000
Template Total0.972896.220.4864
Template load0.00270.270420.0014
Template processing0.970195.905420.4850
Template load and register function0.00020.021710.0002
states
state_id_array0.00200.196810.0020
state_identifier_array0.00110.110920.0006
Override
Cache load0.00240.2362440.0001
Sytem overhead
Fetch class attribute can translate value0.00090.085220.0004
Fetch class attribute name0.00110.104530.0004
XML
Image XML parsing0.00020.024120.0001
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00170.1671100.0002
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs