Forums / Setup & design / How does work view_count ?

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

eZ debug

Timing: Jan 18 2025 04:54:34
Script start
Timing: Jan 18 2025 04:54:34
Module start 'content'
Timing: Jan 18 2025 04:54:35
Module end 'content'
Timing: Jan 18 2025 04:54:35
Script end

Main resources:

Total runtime1.3124 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0087 588.8359180.8359
Module start 'content' 0.00871.1584 769.6719519.1641
Module end 'content' 1.16710.1450 1,288.8359337.4766
Script end 1.3121  1,626.3125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.3319210.0002
Check MTime0.00150.1160210.0001
Mysql Total
Database connection0.00180.133810.0018
Mysqli_queries1.211592.31851940.0062
Looping result0.00200.15251920.0000
Template Total1.275697.220.6378
Template load0.00250.187320.0012
Template processing1.273197.007520.6365
Template load and register function0.00020.013210.0002
states
state_id_array0.00080.058210.0008
state_identifier_array0.00070.055020.0004
Override
Cache load0.00200.1531440.0000
Sytem overhead
Fetch class attribute can translate value0.00140.108130.0005
Fetch class attribute name0.00150.114130.0005
XML
Image XML parsing0.00060.049130.0002
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.02331.7780210.0011
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0003 secs