Development > Development

Improving the items views display, opinions needed.

(1/2) > >>

In relation to this:

My question is: what solution would be faster and would need lower resources in ram and cpu when displaying item views:

1. The actual osclass core functionality with item_stats in DB without a total views/item, and in case you want to see the most viewed items, you must call mostViewed() function that must calculate the views for all items before sorting them.

2. Adding a new table into the db named item_views with 2 columns: item_id and total_views that would be updated like the number of items/user is updated, (+1 for each new visit), when the item_stats table is updated. Then when showing the number of views for an item, you get it from the item_views not by sum of the rows from item_stats.

Also this would mean deleting also the rows from item_views when the ad is deteled.

And there is a bug whith osclass' way of showing the most viewed items't-sort-descending-the-items/

marius-ciclistu: opinions.....

mostViewed method  from item model should belog to itemStats model
 Tracking  views should be optional and decided by admin.there is a waste of resources  just updating a simple counter.
There should be a dedicated plugin where more things can be tracked or let the  G .analitics do the job
External server ,  javascript .. etc..
This is from item controller

--- Code: ---if(!osc_is_admin_user_logged_in() && !($item['fk_i_user_id']!='' && $item['fk_i_user_id']==osc_logged_user_id())) {

require_once(osc_lib_path() . 'osclass/user-agents.php');

foreach($user_agents as $ua) {

if(preg_match('|'.$ua.'|', Params::getServerParam('HTTP_USER_AGENT'))) {

$mStats = new ItemStats();

$mStats->increase('i_num_views', $item['pk_i_id']);





--- End code ---

Finally, an opinion.
Agreed. But my question was which of the 2 options would be more resource efficient.

And I'm not talking about plugins, the core is my interest.


[0] Message Index

[#] Next page

Go to full version