We have popular content table in the database and block associated with it.
My suggestion is to replace Popular Content block with Views plugin to achieve flexibility.

Comments

man-1982’s picture

Added support for module views. Added default views block. Please, see "admin/structure/views". Done.

kalabro’s picture

Not sure that we can modify code in hook_schema in this way. Now I get annoying error before updating:

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
Konstantin Komelin’s picture

Status: Active » Needs work

Thanks, kalabro!
Besides this patch includes changes for #1643374: Remove clear: both;.

man-1982, it would be better to recreate patch according to the comments:
1) Synchronize code with latest branch changes
2) Extract changes for #1643374: Remove clear: both; into a separate patch and attach it to the appropriate issue.
3) Fix issues with database #2

----

Спасибо, kalabro!
Кроме того этот патч включает изменения для #1643374: Remove clear: both;.

man-1982, было бы лучше пересоздать патч с учетом комментариев:
1) Синхронизировать код с последними изменениями в бренче
2) Выделить изменения для #1643374: Remove clear: both; в отдельный патч и приложить его к соответствующему тикету.
3) Исправить проблемы с базой согласно #2

kalabro’s picture

Time to review :)

1. To fix #2 we can use the 4th parameter from db_add_field() function instead of db_add_primary_key():

/**
 * Added primary key.
 */
function yandex_metrics_reports_update_7001() {
  $spec = array(
    'description' => 'The id for url.',
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  );
  db_add_field('yandex_metrics_reports_popular_content', 'yid', $spec, array('primary key' => array('yid')));
}

2. When try to add field “Yandex.Metrics: Title for url” I get: Broken/missing handler. Handler views/handlers/views_handler_field_ym_title.inc should be listed in module .info file.

; Views handlers
files[] = views/handlers/views_handler_field_ym_title.inc

3. Please, add Views to dependencies or check if views is enabled in _yandex_metrics_reports_is_popular_content_enabled(). Otherwise we get "Fatal error: Call to undefined function views_get_view() in sites/all/modules/indev/yandex_metrics/yandex_metrics_reports/yandex_metrics_reports.module on line 1081" while cron running.

4. Unnecessary modifications at the end of yandex_metrics.info file.

man-1982’s picture

Status: Needs work » Needs review
StatusFileSize
new53.54 KB

I've fixed bugs. Please, review my code.

Konstantin Komelin’s picture

Status: Needs review » Patch (to be ported)

Found some non-critical issues in comments format and codding standards.
But the patch looks good in a whole and will be ported.

Konstantin Komelin’s picture

Status: Patch (to be ported) » Needs work

Good job, Andrey!

Team, thank you, it's great example of team collaboration!

I commited Andrey's patch with small corrections: http://drupalcode.org/project/yandex_metrics.git/commit/cda7b04
And my congratulations with the first commit, Andrey!

Could you port your changes to the 6.x-2.x branch?

kalabro’s picture

What about upgrade path? We just decided to leave both old style block and views?

Konstantin Komelin’s picture

StatusFileSize
new77.92 KB

kalabro
I'd like to remove old block code at all. What do you think?

man-1982
You created Views plugin with table instead of HTML list. Any reasons why?
Sorry, I missed it before.

----

kalabro
Я бы хотел удалить старый код с корнями. Что думаете?

man-1982
Ты создал Views плагин в виде таблицы, а не HTML списка. В чем причины?
Прошу прощения, что упустил это раньше.

Скриншот как было раньше:
Yandex.Metrics Popular Content block example

man-1982’s picture

Status: Needs work » Needs review
StatusFileSize
new9.88 KB

I fixed default views according to the wishes in #4

Konstantin Komelin’s picture

Patch from #10 looks good.
Commited with small text correction.
http://drupalcode.org/project/yandex_metrics.git/commit/8819135

Konstantin Komelin’s picture

Status: Needs review » Needs work

Andrey, could you port your changes to the 6.x-2.x branch?

Konstantin Komelin’s picture

Assigned: Unassigned » Konstantin Komelin

I will port Views plugin to 6.x-2.x by myself.

Konstantin Komelin’s picture

Done for 6.x-2.x. It should work with Views 2 as well as Views 3.
Commit: http://drupalcode.org/project/yandex_metrics.git/commit/8b82447

I need somebody to review views integration for 6.x-2.x.

Konstantin Komelin’s picture

Status: Needs work » Needs review
Konstantin Komelin’s picture

Status: Needs review » Needs work

Related task:
Improve text strings. Some strings of Popular Content view should be rephrased.

kalabro’s picture

Adding tag for related task "Improve text strings. Some strings of Popular Content view should be rephrased."

Konstantin Komelin’s picture

Status: Needs work » Closed (fixed)