Creating a Table view of upcoming events (filtered by date > now), the table that is derived gets confused by repeat events.

See the attached jpg.

It seems that when the Views module hits the first repeat event, it then skips everything until the next event in the repeat sequence.

Really, we need the module to take all events in sequence, so that (in my case) the table would show events on 10/4, 10/5, 10/6, etc. and then show the next event in the repeat sequence.

Thanks.

CommentFileSizeAuthor
#2 event.node.jpg61.68 KBgmak
eventlist.jpg221.49 KBgmak

Comments

karens’s picture

I haven't worked with event repeat so I am not sure what it is doing to create the repeat events. I am guessing that something about them looks just the same and that is why they are getting grouped together. Do you have the 'distinct' filter on this view? If so, try removing it.

If that doesn't work, post back with an export of the view you are using, and tell me what the repeated events look like in the database (do they share a nid? Do they have the same name?) and I'll see if I can figure out what else to try.

gmak’s picture

StatusFileSize
new61.68 KB

KarenS,

The problem exists whether 'distinct' is used or not.

This is the view export:

$view = new stdClass();
  $view->name = 'upcoming_events';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '3';
  $view->page_footer = '';
  $view->page_footer_format = '3';
  $view->page_empty = '';
  $view->page_empty_format = '3';
  $view->page_type = 'table';
  $view->url = 'upcoming/events';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = '';
  $view->block_header = '';
  $view->block_header_format = '3';
  $view->block_footer = '';
  $view->block_footer_format = '3';
  $view->block_empty = '';
  $view->block_empty_format = '3';
  $view->block_type = 'table';
  $view->nodes_per_block = '7';
  $view->block_more = '1';
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Event',
      'handler' => 'views_handler_field_nodelink',
    ),
    array (
      'tablename' => 'event',
      'field' => 'event_start',
      'label' => 'Start',
      'handler' => 'views_handler_field_date_small',
    ),
    array (
      'tablename' => 'event',
      'field' => 'event_end',
      'label' => 'End',
      'handler' => 'views_handler_field_date_small',
    ),
    array (
      'tablename' => 'term_node_4',
      'field' => 'name',
      'label' => 'Pathways',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'label' => 'Stage',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'event',
      'field' => 'event_start',
      'operator' => '>',
      'options' => '',
      'value' => 'now',
    ),
    array (
      'tablename' => 'node',
      'field' => 'distinct',
      'operator' => '=',
      'options' => '',
      'value' => array (
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, event, term_node_4);
  $views[$view->name] = $view;

With regard to repeated events; they have the same title but have different nid's.

As far as I can see, the eventrepeat module adds three tables to the database: event_repeat, event_repeat_calendar_map, event_repeat_nodes. The relationship between the event table and the repeat event seems to be via the nid which then maps to an rid (in the event_repeat table). See the attached jpg.

karens’s picture

I can't reproduce this. I installed event repeat and created some dates, than created a view and the repeat events showed up as individual events in the view just as they should. I tried it both with and without the node distinct filter and it worked both ways.

I'll play with it a bit more, but there must be something else unique about your installation that is affecting this. What other modules do you have enabled? What php version are you using? What database OS?

karens’s picture

The only other thing I saw that might affect results is the event repeat settings where you select whether or not to make your events part of a repeat sequence. Which option did you select there? I don't understand yet exactly what that option is doing, but maybe it's a factor.

karens’s picture

One other thought -- You have a filter in your view for event_start > 'now'. Are the missing dates earlier or equal to 'now'? If so, they won't show up, of course.

gmak’s picture

OS = Linux (Fedora Core 4)
PHP = 5.0.4
DB = MySQL 4.1.1

In the settings for repeat event module, I do not have the keep in sequence box ticked.

The dates for the view are well in the future (more than 30 days) so the '>now' filter should not exclude them.

karens’s picture

Still can't replicate it. Could you install the devel module and set it up to display queries, then go to the view that is displaying wrong and scroll down and look at the queries. You will see 2 queries called by pager_query. Could you copy and past those in a message. Obviously something is wrong in the query, but I don't think I can take this any further without seeing what queries are being generated.

Thanks.

karens’s picture

One more thing to try, if you have something like phpmyadmin you can use. Paste the second query you find in the step above into the SQL box in phpmyadmin and see if it pulls up a list of the right events that way.

gmak’s picture

Well, using the devel module is a bit scary. My site shows up loads of notices about "undefined indexes" and "undefined properties". Is that normal?

Anyway, these are the two page_query calls that showed up:

3.26 0 pager_query SELECT count(DISTINCT(node.nid)) FROM node node LEFT JOIN event event ON node.nid = event.nid WHERE (event.event_start > (1157406597 + 0))

2 0 pager_query SELECT DISTINCT(node.nid), node.title AS node_title, node.changed AS node_changed, event.event_start AS event_event_start, event.event_end AS event_event_end, node.type AS node_type FROM node node LEFT JOIN event event ON node.nid = event.nid WHERE (event.event_start > (1157406597 + 0)) LIMIT 0, 10

Also, when I plug the second query into phpMyAdmin, I still get the incorrect output. It is skipping things between the first date of the repeat and the second date of the repeat.

gmak’s picture

Just to let you know, I had been using a fairly heavily patched Event module. So, I just swapped this out for a copy of the most recent Event module and Event Repeat.

But, the problem persists.

Thanks, again, for your assistance.

karens’s picture

The query looks fine and *should* be returning a record for each nid. There must be duplicate or missing nids in one of your tables, that's the only possible reason this query wouldn't work. The event repeat table is not joined in, so that's not a factor, only the node table and the event tables. I need you to look at both and make sure all the relevant nodes exist as indvidual nids in both tables. What I'm thinking is that if you've been using a patched copy of the event module, maybe it wasn't creating a record in the event table for each repeat -- something like that would give you the results you are seeing.

karens’s picture

Also, double check that each of the missing nodes has a value for event_start in the event table that is greater than 1157406597.

gmak’s picture

I've checked the database tables.

The nodes (nid's) are all there. They match up between the node table and event table. All of the nodes have start times that are after 1157406597.

This is very odd.

If it would help, I could email you some access information so you could look at things more directly. For all I know, I might be reading something wrong (my PHP & SQL skills are still quite novice like).

karens’s picture

Status: Active » Fixed

I'm pretty convinced at this point that there is no problem in the module, so I'm marking this fixed. The query that is being created looks just like it should look, so I think it must be something in your database or configuration. Yes, go ahead and email me and I will try to help you get this working.

gmak’s picture

Check out this page: http://www.baade.org/node/425

This is using this snippet:

<?php

function list_ongoing_and_upcoming_events($limit=10) {
global $user;
  // For events coming up in two hours or ongoing events, we display "ongoing now"
  $time = time()  - (2 * 60 * 60);
 // select events that have not yet ended
  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.type, n.status, n.moderate, e.event_start, e.event_end FROM {node} n INNER JOIN {event} e USING (nid) WHERE n.status = 1 AND n.moderate = 0 AND e.event_end >= %d ORDER BY event_start"), $time, 0, $limit);

  while ($node = db_fetch_object($result)) {
    $links[] = $node;
  }

  if (is_array($links) && (sizeof($links) > 0)) {
    foreach ($links as $node) {
      $minutesleft = floor(($node->event_start - time()) / 60);

      if ($minutesleft < 0) {
        $timeleft = t('ongoing now');
      }
      else if ($minutesleft < 60) {
        $timeleft = t('today');
      }
      else if ($minutesleft >= 60 && $minutesleft < (24 * 60)) {
        $timeleft = t('today');
      }
      else if ($minutesleft >= (24 * 60)) {
        $days = floor($minutesleft / (24 * 60));
        // hours remainder
        $hours = ($minutesleft % (24 * 60)) / 60;
        // hours left in the day
        $hours_left = ((time() / 60) % (24 * 60)) / 60;
        // see if the remainder of hours on the event date is greater than the hours left in today, if so increase the days by one so that the days remaining mimics the date rather than how many 24 hour periods there are between now and then.
        if ($hours>$hours_left) {
          $days++;
        }
        $timeleft = format_plural($days, 'tomorrow', 'in %count days');
      }

      $node->timeleft = $timeleft;
      $ctype = module_invoke('flexinode', 'load_content_type', substr($node->type, 10));
      $node->typename = ($ctype->name ? $ctype->name : $node->type);

      //$event_line .= "<div class='upcoming_events'><strong>";
      $event_line .= "<tr><td><strong>" . date('M d', $node->event_start) . "</strong></td>\n";
      $event_line .= "<td>". date('H:i',$node->event_start) ."</td>\n";
      $event_line .= "<td>". date('H:i',$node->event_end) ."</td>\n";
      $event_line .= "<td>". date('O',$node->event_start) ."</td>\n";
      $event_line .= "<td>".l($node->title, "node/$node->nid", array('title' => $node->title))."</td>";
      $event_line .= "<td> (" . $node->timeleft .  ")</td>\n";
      $event_line .= "<td>" .node_get_name($node->type). "</td>";
	 $event_line .= "</tr>\n";
      //$event_line .= "</div>";

    }

  }
  return $event_line;
}

$listlength="20";
  print "<table class='upcoming_events'>".list_ongoing_and_upcoming_events($limit = $listlength)."</table>";
?>

As you can see, it is getting the events in the right sequence, including repeats.

Given, this, I wonder if there isn't something related to the query or handling the results of the query coming from Views.

Thanks

gmak’s picture

Have you had a chance to look into this any further? Thanks

Anonymous’s picture

Status: Fixed » Closed (fixed)