Ad Administration UI column Date Updated not in sync

Created on 5 September 2024, 4 months ago

Problem/Motivation

Updated Date column are not in sync with the recent click event of the Ad

Steps to reproduce

View the Ad Administration page

Proposed resolution

Create a hook_views_pre_render to alter the Updated Date column

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

ad module

Created by

🇵🇭Philippines mikeocana

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mikeocana
  • 🇵🇭Philippines mikeocana
    /**
     * Implements hook_views_pre_render().
     */
    function MODULENAME_views_pre_render(&$view) {
      // Overwrite the 'Updated Date' column to display the recent date event click.
      if ($view->name == 'ad_ui_administration' && $view->current_display == 'page') {
        $results = &$view->result;
        foreach ($results as &$result) {
          $result->node_changed = _MODULENAME_get_ad_recent_click_event($result->nid, $result->node_created);
        }
      }
    }
    
    /**
     * Custom function to get the Ad recent click date event.
     */
    function _MODULENAME_get_ad_recent_click_event($ad_nid, $ad_node_created) {
      $results = db_query("SELECT * FROM {eck_tracked_event} WHERE ad = :nid ORDER BY created DESC LIMIT 1", array(
        ':nid' => $ad_nid
      ));
      // Set default to node_created.
      $created = $ad_node_created;
      foreach ($results as $result) {
        $created = $result->created;
      }
    
      return $created;
    }
    
Production build 0.71.5 2024