signal-desktop/test
Daniel Gasienica 9d84b2f420 Index messages with attachments using a boolean
When indexing message attachment metadata using numeric indexes such as:

```javascript
{
  conversationId: '+12223334455',
  received_at: 123,
  attachments: […],
  numAttachments: 2,
},
{
  conversationId: '+12223334455',
  received_at: 456,
  attachments: [],
  numAttachments: 0,
}
{
  conversationId: '+12223334455',
  received_at: 789,
  attachments: [],
  numAttachments: 1,
}
```

It creates an index as follows:

```
[conversationId, received_at, numAttachments]
['+12223334455', 123, 2]
['+12223334455', 456, 0]
['+12223334455', 789, 1]
```

This means a query such as…

```
lowerBound: ['+12223334455', 0,                1               ]
upperBound: ['+12223334455', Number.MAX_VALUE, Number.MAX_VALUE]
```

…will return all three original entries because they span the `received_at`
from `0` through `Number.MAX_VALUE`. One workaround is to index booleans using
`1 | undefined` where `1` is included in the index and `undefined` is not, but
that way we lose the ability to query for the `false` value. Instead, we flip
adjust the index to `[conversationId, hasAttachments, received_at]` and can
then query messages with attachments using

```
[conversationId, 1 /* hasAttachments */, 0                /* received_at */]
[conversationId, 1 /* hasAttachments */, Number.MAX_VALUE /* received_at */]
```
2018-04-25 15:24:51 -04:00
..
app Eslintify test/backup_test.js 2018-04-20 15:24:04 -07:00
models Introduce intl-friendly sort order for contact lists (#1900) 2017-12-14 16:30:11 -08:00
modules Index messages with attachments using a boolean 2018-04-25 15:24:51 -04:00
styleguide Eslintify test/backup_test.js 2018-04-20 15:24:04 -07:00
views Responding to pull request review feedback 2018-04-23 15:36:47 -07:00
.eslintrc.js Eslintify test/backup_test.js 2018-04-20 15:24:04 -07:00
_test.js Run migrations before clearing database during tests 2018-04-03 11:45:11 -04:00
backup_test.js Responding to pull request review feedback 2018-04-23 15:36:47 -07:00
blanket_mocha.js Fix blanket popup 2014-07-26 19:14:14 -04:00
conversation_controller_test.js Introduce intl-friendly sort order for contact lists (#1900) 2017-12-14 16:30:11 -08:00
crypto_test.js Encryption support for backup and restore 2018-03-20 11:53:54 -07:00
database_test.js Refactor: db tasks to database.js, log delete to modules/logs.js 2018-03-14 14:42:15 -07:00
emoji_util_test.js Upgrade emoji support (#1482) 2017-09-15 13:22:11 -07:00
fixtures.js Fix electron test race condition with protobuf loading 2018-04-20 15:24:02 -07:00
fixtures_test.js Fix electron test race condition with protobuf loading 2018-04-20 15:24:02 -07:00
i18n_test.js Update style of i18n, pull it in via preload instead of .html 2018-04-04 16:03:10 -07:00
index.html Fix electron test race condition with protobuf loading 2018-04-20 15:24:02 -07:00
keychange_listener_test.js Rename createTemporary to dangerouslyCreateAndAdd 2018-03-27 19:52:17 -04:00
libphonenumber_util_test.js Refactor number parsing and validation 2015-12-09 18:58:51 -08:00
manual.txt Add manual test scenarios for remembering window state 2017-09-14 16:53:48 -07:00
reliable_trigger_test.js Override Backbone's trigger with one that catches exceptions 2017-08-04 12:03:25 -07:00
spellcheck_test.js Add spellcheck smoke test 2017-09-14 16:53:48 -07:00
storage_test.js Remove all mention of obsolete safety-number-approval setting 2018-03-14 14:42:15 -07:00