Dentxinho/mantisbt — comment on commit bc992280f1908b5eb94a22e7c865662bda97f182
File:  line 0
By Dentxinho:

@vboctor, i haven't added any queries. I've just changed the IN portion of the where condition.
Instead of always one IN (id, id...) there is now one or two INs:

```sql
(bug_id IN (id, id...) AND view_state = VS_PUBLIC) -- for issues where user can only see public bugnotes
OR
(bug_id IN (id, id...)) -- #for issues where user can see all bugnotes
```

To reproduce it in a full page I used my production server, which has only one project, so i can't show the result if a user has private_bugnote_threshold on only one of N projects. But as you can see in the results, this PR doesn't affect anything on the other queries.

On this test there are 3 private issues. The majority of issues have private bugnotes (the commit message is always put there as private).
Columns viewed are the same. No custom fields viewed.

An user **with** access to private bugnotes viewing the page:
Before: 36 queries (29 unique)
filter_cache_result() produces:

```sql
SELECT DISTINCT bug_id,MAX(last_modified) as last_modified, COUNT(last_modified) as count FROM mantis_bugnote_table WHERE mantis_bugnote_table.bug_id in (6, 62, 61, 60, 59, 57, 53, 58, 50, 42, 55, 54, 51, 43, 34, 52, 56, 30, 48, 47, 41, 37, 33, 32, 45, 49, 35, 46, 44, 38, 27, 29, 36, 31, 28, 26, 40, 39, 25, 10, 23, 22, 16, 24, 20, 21, 12, 19, 7, 14) GROUP BY bug_id
```

After: 36 queries (29 unique)
filter_cache_result() produces:

```sql
SELECT DISTINCT bug_id,MAX(last_modified) as last_modified, COUNT(last_modified) as count FROM mantis_bugnote_table WHERE (mantis_bugnote_table.bug_id in (6, 62, 61, 60, 59, 57, 53, 58, 50, 42, 55, 54, 51, 43, 34, 52, 56, 30, 48, 47, 41, 37, 33, 32, 45, 49, 35, 46, 44, 38, 27, 29, 36, 31, 28, 26, 40, 39, 25, 10, 23, 22, 16, 24, 20, 21, 12, 19, 7, 14)) GROUP BY bug_id
```
____

An user **without** access to private bugnotes viewing the page:
Before: 39 queries (33 unique)
filter_cache_result() produces:

```sql
SELECT DISTINCT bug_id,MAX(last_modified) as last_modified, COUNT(last_modified) as count FROM mantis_bugnote_table WHERE mantis_bugnote_table.bug_id in (6, 62, 61, 60, 59, 57, 53, 58, 56, 55, 54, 52, 51, 50, 43, 34, 41, 30, 37, 33, 32, 45, 49, 35, 46, 44, 38, 36, 31, 29, 28, 27, 26, 40, 39, 25, 24, 23, 22, 16, 10, 20, 21, 19, 12, 7, 18, 14, 11) GROUP BY bug_id
```

After: 39 queries (33 unique)
filter_cache_result() produces:

```sql
SELECT DISTINCT bug_id,MAX(last_modified) as last_modified, COUNT(last_modified) as count FROM mantis_bugnote_table WHERE (mantis_bugnote_table.bug_id in (6, 62, 61, 60, 59, 57, 53, 58, 56, 55, 54, 52, 51, 50, 43, 34, 41, 30, 37, 33, 32, 45, 49, 35, 46, 44, 38, 36, 31, 29, 28, 27, 26, 40, 39, 25, 24, 23, 22, 16, 10, 20, 21, 19, 12, 7, 18, 14, 11) AND mantis_bugnote_table.view_state = 10) GROUP BY bug_id
```