Commit Graph

74 Commits

Author SHA1 Message Date
Zev Benjamin 1a6929d9ae Handle get_old_messages case where num_before = 0 and num_after = 0 and a narrow is specified
Previously, we assumed that num_before or num_after would be always be non-zero
after adjustment for the anchor.  However, we don't adjust num_before or
num_after when a narrow is specified.

(imported from commit 9239fef140e109b11bdfbeef42e9fbed78660ad1)
2014-02-19 12:24:17 -05:00
Steve Howell 8b58d8574b Use check_bool instead of json_to_bool.
(imported from commit 52eb892a92e293d6ecb854c51bd7bd32355206c9)
2014-02-18 13:02:08 -05:00
Steve Howell 91445035bc Add NarrowBuilder support for negated search conditions.
(imported from commit cdc426e342a6d735d321d78b6753ca5ad7c79c6f)
2014-02-13 14:14:25 -05:00
Steve Howell fb27cbcd01 Handle negated streams in ok_to_include_history.
(imported from commit 0a049364e1d14f45db9f8e9aa5392039a01231eb)
2014-02-13 14:14:25 -05:00
Steve Howell 11ba6a17ab Extract ok_to_include_history() method in messages.py.
(imported from commit a88f5455bf658a8c52c92e7f0bedc301a605020b)
2014-02-13 14:14:25 -05:00
Steve Howell 2fb7c0059d Support negated searches on staging.
Behind a feature flag you can now do searches like this:

    -pm-with:othello@example.com is:private

The "-" in front of "pm-with" tells us to exclude messages
with Othello from our search.  We support "-" in front of
all operators, although the behavior for "-search:" and
and "-near:" doesn't really change in this commit.

Note that the filtering out of "negated" predicates only
happens on the client side in this commit.  On the server
side we ignore negated predicates and send back a superset
of the results.

(imported from commit 6cdeaf32f2d493fbbb838630f0da3da880b1ca18)
2014-02-13 14:14:24 -05:00
Steve Howell 90bb689e13 Extract "cond" local var in NarrowBuilder methods.
This commit doesn't change any functionality, and it is
designed to make diffs for upcoming changes related to
negated conditions a bit easier to read.  This diff
looks a bit noiser than it really is due to some
reindentation of continuation lines.

(imported from commit 64c1cba98faa4bad4eaad122dd3de119caa880c0)
2014-02-12 16:58:07 -05:00
Zev Benjamin 25d461c8f5 Exclude messages on muted topics when finding the first unread message in a narrow
(imported from commit 3151c401f689cc77e53cf34ffc49c7fd7d0a771a)
2014-02-12 16:23:34 -05:00
Steve Howell ea8d9efa00 Support dictionary-style narrows in back end API.
(We continue to support tuple-style narrows as well.)

(imported from commit 0154c1cba7503471b112ce22f280b619133e0211)
2014-02-11 13:15:42 -05:00
Steve Howell a2acce2905 Phase out search tuple data structure in messages.py.
The narrow_parameter convert now converts tuples of
(operator, operand) into dictionaries so that downstream
functions/classes deal in dictionaries.  This
affects get_old_messages_backend, messages_in_narrow_backend,
and NarrowBuilder.

(imported from commit 7e8cb887f7872ec687acd8c4857d1d5222ab0d5f)
2014-02-11 11:52:31 -05:00
Tim Abbott f26af47fb6 Center on-page-load narrows on first unread message.
This implementation is somewhat hackish in large part because I think
we're going to be wanting to redo the get_old_messages API somewhat
soon, and this may naturally become a lot cleaner as a result, but
this isn't a lot of code and fixes #2235 part (A) and substantially
mitigates #1510.

(imported from commit 47a2160a44befa9d83190c5cc95b90e92cc5b4cc)
2014-02-03 13:32:02 -05:00
Tim Abbott 7ef68f19da Log operation and flag in update_message_flags.
(imported from commit c720224b0b3bf2f8ac1fd686acac143ea3f64994)
2014-01-30 12:48:36 -05:00
Jessica McKellar eeb8464f4d Don't expose deactivated streams to users through clients or API.
(imported from commit c32715255b3286f52fb313d35659f9357082603a)
2014-01-29 12:41:21 -05:00
Zev Benjamin f015d27d31 Disable historical search whenever the 'is' operator is present
Previously we only disabled it for 'is:starred'.  This caused a backtrace when
someone searched for, say 'stream:test is:mentioned', because we weren't joining
on zerver_usermessage, which meant the flag wasn't available to filter on.

(imported from commit ba19f8a74b21d60b89dfc8dbe9c8458ed86b423b)
2014-01-15 16:07:20 -05:00
Zev Benjamin d8d1d6ea40 Fix narrowing to PMs with yourself
(imported from commit 1326fa7ae779ba6476165e8838e46ce1323e3ecb)
2014-01-15 16:07:19 -05:00
Zev Benjamin 3679889be2 Remove extraneous function argument
(imported from commit 4f90f98632077c771ac3123051a6d1a2804fb168)
2014-01-14 11:47:12 -05:00
Zev Benjamin 45ab625616 Add tests for get_old_messages DB queries
(imported from commit 1d6c871e6ac56324a129567e1ba447d44197a0aa)
2014-01-14 11:47:12 -05:00
Zev Benjamin df4d4beb6c Add TODO comment to messages_in_narrow_backend
(imported from commit 7e80a84fdd8f6ba347bb4ecb0f9238923b825871)
2014-01-14 11:47:12 -05:00
Zev Benjamin 64c6bfecac Remove use_raw_query special case in get_old_messages_backend
The normal code will now generate SQL that is basically identically to the raw
SQL we were using before.

(imported from commit 84a3971d6137d05ef3f71252278afdd59041e86a)
2014-01-14 11:47:12 -05:00
Zev Benjamin fe6dc2ef81 Port get_old_messages to use SQLAlchemy
This commit also includes a few changes in the way we do some queries that
should speed searches up:

* Messages before and after the anchor are fetched in a single query by doing a
  UNION ALL on the server.  This incurs the cost of an extra sort because UNION
  ALL does not guarantee the order that the results are appended, but it saves a
  server round-trip.
* Searches involving flags now use a straight froward WHERE clause, which is
  much faster than the one that django-bitfield generates (due to limitations of
  the Django ORM)

(imported from commit a0db811a9073363cfabcf4b035d02d20dc8fc8a4)
2014-01-14 11:47:12 -05:00
Zev Benjamin 8142646938 Remove non-Postgres search codepath
(imported from commit ebc71defce2f075ee224f17a40088ccda9fab931)
2014-01-14 11:47:12 -05:00
Zev Benjamin 6c96561624 [manual] Do search highlighting in Python rather than in the database
This requires the tsearch_extras Postgres extension.  To install the extension,
first install postgresql-9.1-tsearch-extras on both postgres-primary and
postgres-secondary (this would normally be done in a puppet apply, but there are
currently some changes that can't be applied on Postgres machines).  Then run
the following as the postgres user on postgres-primary:

$ psql -d zulip -c 'CREATE EXTENSION tsearch_extras SCHEMA zulip;'

In dev environments, you must also run:

$ psql -d zulip_test_template -c 'CREATE EXTENSION tsearch_extras SCHEMA zulip;'

(imported from commit ad0a57c455b3b86002191ac5fb705d8f716f3296)
2014-01-14 11:47:12 -05:00
Jason Michalski 75d1366ae1 Fixes how user input is escaped in stream and topic regexes
NarrowBuilder.by_stream and NarrowBuilder.by_topic for mit users uses a
regex to search by stream and topic. Python's re.escape escapes unicode
in a format that postgres can not parse. We escape unicode as '\uXXXX'
for postgres.

(imported from commit d2c27d4514c31fdc6ef1fea898fe721a6f0ab069)
2014-01-10 21:38:59 -05:00
Zev Benjamin 3720cb1c33 Move message-related views into their own file
(imported from commit 2c71cc1b5d3f0210c98767888c461d5c6d046b49)
2014-01-10 21:38:59 -05:00