I'm trying to create a view that list all the nodes that have a flag count < 4.

But basically, what it does is listing the nodes with flag count of 1, 2 and 3 but not the ones with no flag.
I'm pretty sure, it comes from the fact that NULL is not a number, but how can I solve this ?

Thanks !

Comments

quicksketch’s picture

Status: Active » Fixed

- Add a "Flags: Node flag counter" relationship, select the flag you want.
- Add a "Flags: Flag counter" filter, limit to content flagged less than 4

This request was opened months ago, so I'm going to preemptively mark it fixed. Please reopen if you have further questions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

halldb02’s picture

Following the steps in comment (1) #comment-2041520 is how you get to the point where you experience the problem outlined by the post.

The bug is also exactly what the poster thinks it is: NULL is not a number, so a post which is not flagged as offensive will get filtered out just the same as if it was above the threshold.

However, the problem may partly be with Views.

This is how I modified function op_simple in views_handler_filter_numeric.inc to fix the problem:

  function op_simple($field) {
    if ($this->operator == '<' || $this->operator == '<=') {
      $this->query->add_where($this->options['group'], "$field IS NULL OR $field $this->operator %d", $this->value['value']);
    }
    else {
      $this->query->add_where($this->options['group'], "$field $this->operator %d", $this->value['value']);
    }
  }

It might be better implemented as an override handler that is included with Flags.

halldb02’s picture

Status: Closed (fixed) » Needs work

Comment #515814-1: Create a view of nodes with a given number of flags or no flags actually outlines steps to reproduce the problem, it does not fix the problem.

BenK’s picture

Subscribing....

quicksketch’s picture

Status: Needs work » Closed (fixed)