una icon indicating copy to clipboard operation
una copied to clipboard

Timeline: Improve events grouping

Open AntonLV opened this issue 1 year ago • 2 comments

Use 'source' field in SQL queries instead of serialized 'timeline_group' => ['by' => '...', 'field' => 'owner_id'] in PHP.

Update code with "TODO: Should be updated when GROUP BY source will be used in sub selects."

AntonLV avatar Apr 12 '24 10:04 AntonLV

Now group by 'source' is used in Validation query.

AntonLV avatar Apr 12 '24 11:04 AntonLV

In the next update add the following code:

$oDb = BxDolDb::getInstance();
$aEvents = $oDb->getAll("SELECT * FROM `bx_timeline_events` WHERE `source`='' AND `content` LIKE '%timeline_group%'");
foreach($aEvents as $aEvent) {
    $aContent = unserialize($aEvent['content']);
    if(!empty($aContent['timeline_group']) && is_array($aContent['timeline_group']))
        $oDb->query("UPDATE `bx_timeline_events` SET `source`=:source WHERE `id`=:id", [
            'id' => $aEvent['id'],
            'source' => $aContent['timeline_group']['by']
        ]);

It may be useful for old records which don't have a value in source field.

AntonLV avatar Jul 08 '24 12:07 AntonLV