*

MB Themes

Re: Random display of ads in the premium block does not work
« Reply #15 on: February 13, 2023, 08:27:05 AM »
@Alex_PY
I've just reviewed Osclass core code and this is query used:
Code: [Select]
select oc_t_item.*, oc_t_item.s_contact_name as s_user_name
FROM (oc_t_item, oc_t_item_stats)
WHERE oc_t_item_stats.fk_i_item_id = oc_t_item.pk_i_id
AND oc_t_item.b_premium = 1
AND oc_t_item.b_enabled = 1
AND oc_t_item.b_active = 1
AND oc_t_item.b_spam = 0
GROUP BY oc_t_item.pk_i_id
ORDER BY SUM(oc_t_item_stats.i_num_premium_views) ASC, RAND()
LIMIT 0, 4;

means it use random order and besides that, it's quite progressive way to show premiums.
What it does is, that it says: pick 4 premium items with least views (viewed as premium item in premium block) and randomize them.
What it wants to achieve is to keep same premium views on all listings.

Let's say there are 4 items with 1000 views and 1 new with 0 views.
New item will always be picked with randomized 3 from 4 original until they are on same level with premium views.
If customer ask you why its listing is not shown anymore, it's not "anymore", it is simply because everyone paid same amount, means all listings should get same "priority" to be shown as premium.

In order to see number of "premium views", these are shown in backoffice in listings tab (last column - Views) if there are any, in format:
Quote
14x / 73766x

73766 means listing was shown 73766 time as premium one.
From Osclass v8.1.1 are premiums also cached, so you should see for period of caching same listings (usually 1 minute). This may be good if you see some premium item on home page or in premiums block, you may want to go back to see it again but it will not be there anymore as it randomized list.

In Osclass v8.1.2 there will be improvement, that cached results are only related to logged user or user session ID. So they randomize by different visitors, but keep in cache for minute for same user.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots