Commit Graph

6778 Commits

Author SHA1 Message Date
Tim Abbott 3846494f9e Decrease font size for block code blocks to match other text.
Currently, code blocks end up with scrollbars annoyingly frequently --
even with a maximum width window, you can't fit a standard 80
character terminal worth without needing a scrollbar.  This change
causes our code block text to be the same size as normal text and
inline code blocks.

(imported from commit c2fc7e008cc514e90387f8f0db2b49e357cf4f62)
2013-10-21 14:59:19 -04:00
Tim Abbott 8f1fc7c968 Update mirroring backend to support IRC mirrors.
(imported from commit 771aa59b780da0aed2fc7e43d20229e7f42ad06d)
2013-10-21 14:39:21 -04:00
Tim Abbott c34be3a91f Make the forged_timestamp field optional for mirror messages.
(imported from commit 6d03d374bce0d59b0e13c944af7b620a7336a86f)
2013-10-21 14:37:36 -04:00
Tim Abbott d58b4e92dd Add irc-bot@zulip.com as an API superuser.
(imported from commit 36aa0faf8c3ccd8454f214986f32da4f37236921)
2013-10-21 14:37:36 -04:00
Tim Abbott 924c5fea24 api: Add support for specifying client using zulip.init_from_options.
(imported from commit f92db44af606d67d5a1dcc9c978cee0d079d466d)
2013-10-21 14:37:36 -04:00
Tim Abbott 080f5922e1 lint-all: Fix gotcha regexps to not misparse certain quoting cases.
(imported from commit fed305fce9cf6f88e05f4d7310e25928ae6add4b)
2013-10-21 14:37:36 -04:00
Tim Abbott bd107dbb4e logging: Properly log the client for / as website.
(imported from commit 5d3cbbd26994dc5dd6d605a056947dbae19810a8)
2013-10-21 14:33:24 -04:00
Tim Abbott 5806a6e508 logging: Log the type of the narrow for get_old_messages.
(imported from commit 9e6471c10602242c924f29d29bc780667ac17672)
2013-10-21 14:33:24 -04:00
Tim Abbott 1d4f39f55a logging: Update slow query logger to not display client string.
I believe with this change the log lines will fit much better into
Zulip, and the Client string was I suspect rarely important for
responding to slow queries (and is always available in the main log
anyway).

(imported from commit ad56f446bf3fb96a14a56b825f46c1dad9b6babe)
2013-10-21 14:33:24 -04:00
Tim Abbott f3fee40d1d logging: Don't log query parameters for GET requests.
(imported from commit 4f764ae0168f6b0ad73d13a15ca7e0895514951c)
2013-10-21 14:33:24 -04:00
Kevin Mehall bd58861b09 Ignore summarized messages when calculating rendering windows.
Summary blocks can contain hundreds of messages. When the rendering window
code didn't take this into account, it would lead to all kinds of
unpleasant behavior when you scroll.

Trac #1888

Unfortunately, this replaces a subtraction with a function that iterates
through all the messages.

(imported from commit 9259a246946cd968a8725c38ff5ef2d4b4793717)
2013-10-21 11:48:57 -04:00
Kevin Mehall ba87ebc246 Fix duplicated summary blocks when scrolling up.
Make prepend re-render the whole render window instead of just the added
messages.

(imported from commit 6270a33ff0fe98fc901b687ca533ef0ea127d052)
2013-10-21 11:48:56 -04:00
Kevin Mehall a528b7134c Move summary_adjective to its own method
(imported from commit d451ffcf3ff460ffe030e265ca83fec1094c6217)
2013-10-21 11:48:56 -04:00
Kevin Mehall 463b10cf0e Enable summarization only for the right narrows.
* Disable for search-like narrows (whitelist stream and home instead of
    blacklisting topics and PMs)
  * Use home view summarization flag for All Messages

(imported from commit 48bd10ae5da7c7564c2efe86a40078f1a7e96e20)
2013-10-21 11:48:56 -04:00
acrefoot e35e2d62b4 In invitation reminders, take advantage of realm names
(imported from commit 68607b015c640529d4d65065ace82a18d57610a3)
2013-10-21 11:33:34 -04:00
acrefoot 1d6e841964 Queue invitation reminder email
The queued email gets deleted if the user signs up before it gets sent.
Otherwise, they are reminded in 2 days that they still haven't signed up.

This addressses Trac #1812

(imported from commit c1bdc09c03ac576b08986e56994de72d52fd293b)
2013-10-21 11:08:38 -04:00
acrefoot 776feb84e9 Make mandrill actions better
clear_followup_emails_queue now filters by from_email too
send_local_email_template_with_delay passes the template_payload into the subject template

(imported from commit 8044fe2ebad90a9d6d5c67cdfdd08801760fd7f7)
2013-10-21 11:08:38 -04:00
Steve Howell 03c856ce10 Add create-stream management command.
The current version should only be used for testing; for example,
if you want to create a bunch of streams for stress testing, you
can run this in a loop.

(imported from commit ec51a431fb9679fc18379e4c6ecdba66bc75a395)
2013-10-19 09:28:59 -04:00
Steve Howell e0fa6e427b Tone down postgres lock warnings
(imported from commit 11cad022a15b3269294c59b9acd2a8fab2a52a5f)
2013-10-18 17:05:45 -04:00
Tim Abbott eaaf0fec04 [schema] Add case-insensitive index on stream names.
We need to run the schema migration manually using

"CREATE INDEX CONCURRENTLY upper_stream_name_idx ON zerver_stream ((upper(name)));"

since we need CONCURRENTLY and I seem to recall that doesn't work with South.

This significantly improves the uncached performance of get_stream()
(e.g. from 32ms to 9ms).  At present, this codepath is not used
particularly heavily since we do cache the stream names and do most of
our filtering by recipient ID, but the index isn't expensive and does
provide a significant improvement in the uncached case.

(imported from commit 4d28dc2e9a02d0602861b165393d90ed18f5f4c8)
2013-10-18 16:38:31 -04:00
Tim Abbott 4d94d4d6f6 [schema] Add case-insensitive index on message subject field.
We need to run the schema migration manually using

"CREATE INDEX CONCURRENTLY upper_subject_idx ON zerver_message ((upper(subject)));"

since we need CONCURRENTLY and I seem to recall that doesn't work with South.

Apparently our existing indexes on subject/topic weren't being used in
our narrowing queries, because we do case-insensitive search.

This substantially improves our database performance around
stream+topic narrows.  See before and after query plans below from my
test instance.

humbug=# explain analyze SELECT "zerver_message"."id" FROM "zerver_message" WHERE ("zerver_message"."recipient_id" = 38  AND UPPER(zerver_message.subject) = 'TEST'  AND "zerver_message"."id" <= 348495 ) ORDER BY "zerver_message"."id" DESC LIMIT 50;
                                                                       QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=13510.61..13510.71 rows=41 width=4) (actual time=32.952..32.958 rows=2 loops=1)
   ->  Sort  (cost=13510.61..13510.71 rows=41 width=4) (actual time=32.946..32.947 rows=2 loops=1)
         Sort Key: id
         Sort Method: quicksort  Memory: 25kB
         ->  Bitmap Heap Scan on zerver_message  (cost=237.99..13509.51 rows=41 width=4) (actual time=2.357..32.912 rows=2 loops=1)
               Recheck Cond: (recipient_id = 38)
               Filter: ((id <= 348495) AND (upper((subject)::text) = 'TEST'::text))
               ->  Bitmap Index Scan on zephyr_message_recipient_id  (cost=0.00..237.98 rows=8221 width=0) (actual time=1.178..1.178 rows=10354 loops=1)
                     Index Cond: (recipient_id = 38)
 Total runtime: 33.049 ms
(10 rows)

humbug=# explain analyze SELECT "zerver_message"."id" FROM "zerver_message" WHERE ("zerver_message"."recipient_id" = 38  AND UPPER(zerver_message.subject) = 'TEST'  AND "zerver_message"."id" <= 348495 ) ORDER BY "zerver_message"."id" DESC LIMIT 50;
                                                                          QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=435.11..435.22 rows=41 width=4) (actual time=4.998..4.999 rows=2 loops=1)
   ->  Sort  (cost=435.11..435.22 rows=41 width=4) (actual time=4.997..4.997 rows=2 loops=1)
         Sort Key: id
         Sort Method: quicksort  Memory: 25kB
         ->  Bitmap Heap Scan on zerver_message  (cost=275.63..434.02 rows=41 width=4) (actual time=4.981..4.984 rows=2 loops=1)
               Recheck Cond: ((upper((subject)::text) = 'TEST'::text) AND (recipient_id = 38))
               Filter: (id <= 348495)
               ->  BitmapAnd  (cost=275.63..275.63 rows=41 width=0) (actual time=4.954..4.954 rows=0 loops=1)
                     ->  Bitmap Index Scan on upper_subject_idx  (cost=0.00..37.38 rows=1744 width=0) (actual time=2.972..2.972 rows=27457 loops=1)
                           Index Cond: (upper((subject)::text) = 'TEST'::text)
                     ->  Bitmap Index Scan on zephyr_message_recipient_id  (cost=0.00..237.98 rows=8221 width=0) (actual time=0.855..0.855 rows=10354 loops=1)
                           Index Cond: (recipient_id = 38)
 Total runtime: 5.049 ms
(13 rows)

(imported from commit 1f4815ccb0691053ff8d505149482dbc74153fb3)
2013-10-18 16:38:31 -04:00
Kevin Mehall 89d149c6f7 Fix @-mention "not subscribed" warning for all_public_streams bots.
Don't warn when @-mentioning a bot on a public stream that it does
not appear to be subscribed to. It may be receiving those messages
anyway.

(imported from commit 4a00694942a721897a01736f48033c71048e0b16)
2013-10-18 14:55:32 -04:00
Kevin Mehall 7b8dea3d54 Add all_public_streams parameter to register API.
It makes the event queue return all messages on public streams, rather
than only the user's subscriptions. It's meant for use with chat bots.

(imported from commit 12d7e9e9586369efa7e7ff9eb060f25360327f71)
2013-10-18 14:55:32 -04:00
Jessica McKellar 06566b3776 Don't receive notifications for messages on muted topics.
This doesn't address the more complicated case of someone @-mentioning
you on a muted topic, which consensus is you do want to get
information for, but we need to develop some infrastructure to present
that case to users clearly.

(imported from commit a4bc1e89c108fa8ba6eccc0a198eabf2231326ab)
2013-10-18 14:38:31 -04:00
Jessica McKellar efda426b86 notifications: split message_is_notifiable into multiple ifs for clarity.
(imported from commit 33d1e2135a87192cc4d964db534b31ae9335595a)
2013-10-18 14:38:31 -04:00
Tim Abbott 21b085b1d4 get_old_messages: Improve our use_raw_query queries.
By far the common case for get_old_messages is the home view loading
queries, for which we have raw queries.  This patch substantially
improves those queries using the observation that we weren't actually
using the zerver_message table that we were joining with.

I actually expect this to result in a noticable performance
improvement for loading of the homepage.

(imported from commit 12807e5a74eb63275b2523a5f62fd901ab632f0f)
2013-10-18 13:44:29 -04:00
Steve Howell ca454b4e43 Add query for at-risk users to /queries.
(imported from commit b3b631211d233e6e76050a5bee6e43f78d2fa930)
2013-10-18 12:05:40 -04:00
Zev Benjamin b961c16265 zephyr_mirror: Make outgoing zephyrs to ctl instead go to golem
This makes zulips to ctl@mit.edu cause the mirroring system to zephyr
golem@mit.edu.

(imported from commit 9059a92ba51fa87e45feae2f0d5549b36b048e8b)
2013-10-17 23:20:57 -04:00
Steve Howell c0bf3bb191 [deploy] Have most queue works commit on success.
Deployment instructions: I think all the queue workers get
restarted automatically, so there is probably nothing special
to do here in the deploy itself, but we will want to monitor
it closely, and the change should make our number of locks go
down.

QueueProcessingWorker.start() now calls consume_and_commit(),
which ensures that we don't hold locks after work actions
by using Django's commit_on_success() decorator.

Obviously, workers that override start() will not call consume_and_commit()
through this code path.  SlowQueryWorker calls commit_on_success()
in its start() method now, and I hope to address MissedMessageWorker soon.

(imported from commit f3f38a7f45730eee8f3b5794371ba5b994017676)
2013-10-17 15:36:39 -04:00
Steve Howell 60dfd4b1b4 Test UserActivityWorker.
This commit also introduces a mechanism to stub out
SimpleQueueClient.

(imported from commit b88f963926b469c6eeec1f84323c1b520979b0e2)
2013-10-17 15:36:39 -04:00
Jessica McKellar b7419d50b4 create_realm: add a reminder to run set_default_streams.
(imported from commit 59cf9378f8f271a88a6fbda591814fd9142a8d93)
2013-10-17 13:47:51 -04:00
Jessica McKellar a9c7f3a387 [manual] Use the name instead of the domain for the user-visible realm identifier.
Do not push this commit to prod until the historical realm names have
been populated.

(imported from commit a58191d181d2fb2b8b5e9793ea57707b36812cfc)
2013-10-17 13:47:51 -04:00
Jessica McKellar 6dbf7613a1 Supply a name when creating realms.
For our populate_db bulk creation, just use the domain.

(imported from commit 4fb756f6dfa2d8f90e55822e27891e84168d5d1c)
2013-10-17 13:47:51 -04:00
Jessica McKellar 5c5ffd6ea3 [schema] Add a name field to zerver_realm.
(imported from commit 5b5d7a40d5dff11fe9ca6624b3794cb9c8a3520a)
2013-10-17 13:47:51 -04:00
Jessica McKellar 648b3bed74 create_realm: don't let us create realms with invalid domains.
(imported from commit 95a75a941b18d0857027084f5f9ea4c011805c9d)
2013-10-17 13:47:51 -04:00
Steve Howell 4a61ea38b2 Adjust warn/error parameters for postgres locks (more aggressive).
Setting values to 15 (warn) and 100 (error).

(imported from commit efda53fe04c7739a368aec449de7d43f181e61fb)
2013-10-17 13:21:54 -04:00
Steve Howell f2be9f046a Create /queries page with canned queries for Waseem.
These are some queries on API usage, desktop usage, and
Android usage that would be of interest to Waseem.  These
will eventually be subsumed into /activity, but some interim
data issues may make them easier to keep separate for now.

(imported from commit 697a8496cbf4447d557a3fc89f64c1c4d3e67e70)
2013-10-16 23:40:04 -04:00
Zev Benjamin 890bfe1e95 puppet: Up the Postgres autovacuum_freeze_max_age and related parameters
These parameters collectively determine when very old transaction ids
are replaced with the special FrozenXID transaction id, which is
older than any other transaction id.  Old transaction ids must be
periodically replaced like this to prevent transaction id wraparound.

The only disadvantage of increasing autovacuum_freeze_max_age is
increased disk usage, but a value of 2 billion should only require
500MB, which is pretty trivial.

Since changing autovacuum_freeze_max_age requires a restart, we will
still have to issue a manual VACUUM, with vacuum_freeze_min_age and
vacuum_freeze_table_age temporarily set to lower values.

(imported from commit 22f9ecdfc5b6a07918771d541192aa6d6369878a)
2013-10-16 21:44:17 -04:00
Jessica McKellar 387bdb01c2 twitter-search-bot: update the path to the bot in the help.
(imported from commit c1097685870029d9f6e7d0ba5a9e61912cf00885)
2013-10-16 21:26:01 -04:00
Jessica McKellar 6e6e054024 twitter-search-bot: add the version requirement for twitter-python to the help.
(imported from commit dbee40c3081e50b07a80a297691acf98f4aaf89a)
2013-10-16 21:26:01 -04:00
Jessica McKellar 8bc6e61071 twitter-search-bot: Consistently capitalize Twitter.
(imported from commit 1c8f0b526d0112c05c91b69a77081ec361da538c)
2013-10-16 21:26:01 -04:00
Jessica McKellar cd62c77e08 integrations: add the Twitter search bot.
(imported from commit 9afca400889baae3b90b53cbe1efa8ccf7b798a7)
2013-10-16 21:26:01 -04:00
Leo Franchi 753aace8f8 Add a basic statistics module to analyze active user engagement
(imported from commit 4d7a21b9a09b97c88a80d0446fb16e53012507c9)
2013-10-16 18:39:44 -04:00
Leo Franchi 15695ebfa3 Add zulip-events-slowqueries to our zulip-workers group in supervisor so it is restarted
(imported from commit bcb4037c3323f0be6e671365b6ef7eec47030915)
2013-10-16 15:33:35 -04:00
Jessica McKellar d4e2cdd09e Determine DEPLOYED only based on /etc/humbug-server.
The other zulip.net check was for a transition to using that file that
has now completed.

(imported from commit 991d9165515b5611865957255f9da7a69a75fd7b)
2013-10-16 13:18:49 -04:00
Leo Franchi f7386c3f58 [schema] Add support for keeping track of iOS APNS device tokens
In order to support iOS Push Notifications, we need to keep track
of a device's unique APNS Token. These are delivered to our iOS
code after registering for remote notifications

(imported from commit bbe34483e1380dc20a1c93e3ffa1fcfdb9087e67)
2013-10-16 12:54:28 -04:00
Steve Howell 5904f2eb8d Avoid locks between logging slow queries.
Use the commit_on_success() context manager around the call
to internal_send_message() inside of SlowQueryWorker's polling
loop, so that the pending SELECT statement from
get_status_dict_by_realm() gets committed.  If we don't do
this, postgres will hold locks on zerver_userprofile, and other
tables, for a long time, which can interfere with migrations.

This is an interim solution until we switch postgres's default
commit behavior.  Right now the default transaction isolation
is "read committed," so SELECT statements lead to AccessShareLocks
that do no get closed until the transaction finishes.

(imported from commit f72aeffbbe71a731e327459f15bd7dbebaf9e0b8)
2013-10-16 11:34:41 -04:00
Kevin Mehall 71decdbe7a Fix code block auto-closing.
Trac #1162

The process_fence method replaces code blocks with placeholders, so
indexes stored before the replacement are incorrect. However, because
the closed code blocks have been replaced, we can simply search the
whole string for any remaining opening code block markers.

(imported from commit 6a9e6924840f8f3ca5175da7c52a905e27c1fabd)
2013-10-16 10:12:33 -04:00
Kevin Mehall b134c90b6b Enable backtick fenced code blocks.
Trac #1900

(imported from commit 47b3a76488a4285641fd1eb3e68bc72047a8d738)
2013-10-16 10:12:33 -04:00
Jessica McKellar da3b394a64 Specify the email input type for the email login field.
(imported from commit 2c2ff574627fd7d933512d9bb0585aa948ea536a)
2013-10-15 17:40:16 -04:00