Commit Graph

586 Commits

Author SHA1 Message Date
Steve Howell db398d5e41 Send ids, not emails, of subscribers when loading the page.
(imported from commit 26bbf38664d246476df7062432fa20add7d4cb11)
2013-10-22 15:51:18 -04:00
Steve Howell 3b59952ea3 Extract gather_subscriptions_helper().
The gather_subscriptions_helper() does a separate query to
get emails from user_ids, and it returns an email_dict to its
caller.

This may seem like a step backward, since gather_subscriptions()
now needs to do an additional query, but there is some benefit
in passing fewer redundant emails over the wire from the DB.
The real payoff, though, will come in subsequent commits, where
we will reduce the amount of data going over the wire to the browser,
which will benefit users with slow connections.

(imported from commit bf1cc5828a4c5f68cafd052ea29a177837970206)
2013-10-22 15:51:18 -04:00
Steve Howell 58acef4098 Add get_emails_from_user_ids() action.
(imported from commit 887090de16f685373bd2f3548bd1ec94a7ad4a9e)
2013-10-22 15:51:18 -04:00
Steve Howell 4a53a6680e Test external API for listing subscriptions.
I am about to change the behavior of the internal API, and it's really more
important to have test coverage on the external API anyway.

(imported from commit 8a0723cbcb4ac1819a63397584aa40e69ceb827d)
2013-10-22 15:51:18 -04:00
Zev Benjamin c665139012 blueslip: Send the log back to the server when reporting errors
(imported from commit 013057a8ddc2ddb73b03b0de5c139052b22f5319)
2013-10-22 15:39:17 -04:00
Steve Howell cf0331018a Log client/email in zulip_internal decorator.
(imported from commit 43b7ae75bd5cd3e8a086f82b31507079d999a42b)
2013-10-22 15:03:34 -04:00
Tim Abbott b5fbf67511 bugdown: Fix support for python-markdown >= 3.2.1.
(imported from commit c3c61ad3f75ef0019517084278e34641998a7e22)
2013-10-22 14:44:46 -04:00
Steve Howell c841c0abc0 Remove unused /activity tabs.
The Mirror and iPhone tabs were either unused or misleading
for realm-specific pages of the /activity report.

(imported from commit 8d0a99eac6657fbfd9e6a32f22739eed66e03fbf)
2013-10-22 14:05:12 -04:00
Steve Howell 8711f7450d Add History tab to /activity for realm pages.
(imported from commit 8d51da01ff8a9f4668aca7408b3ccbf9d862b81c)
2013-10-22 14:05:12 -04:00
Tim Abbott b340add1aa bugdown: Disable linebreaks from two spaces at end-of-line.
Arguably the nl2br extension should be doing this for us.  Given that
we're using nl2br, the "two spaces at the end of a line makes a line
break" rule doesn't make any sense (since every newline leads to a
linebreak), so we disable it.

(imported from commit 5ffa2ac8a825642ad31e085c532091e076665710)
2013-10-22 14:04:11 -04:00
Kevin Mehall db71931dab Include is_bot in new user event
(imported from commit 4ae4daaa3ce9b2c2546e1469cc179d209a02c313)
2013-10-22 13:42:22 -04:00
Steve Howell 3be5b9ba0a Fix Activity Test to account for more queries.
(imported from commit f8fa6a1054b2248104e1a4941e9c45f6edd06269)
2013-10-22 12:05:12 -04:00
Steve Howell 124292e556 Remove stray print
(imported from commit 88911bf8ce610de72947e7b4bf0f2eccffa86bd7)
2013-10-22 12:04:05 -04:00
Steve Howell 760e6483c4 Report on Hubot and friends on /activity.
This fixes the following two closely related tabs:

    Integrations by domain
    Integrations by client

They now blacklist clients instead of whitelisting them, so
we can see newcomers like Hubot and Giphy bot.  Our naming
convention still leaves a lot to be desired.

(imported from commit 66cbd07160d93e4b745a1439261330d854700a5c)
2013-10-22 11:59:27 -04:00
Steve Howell 3be4641625 Subsume /queries into the main /activity report.
This moves the reports from /queries into six new tabs on the
main /queries report.

(imported from commit e4ccf6e7edfc900d929e85613f21437b40f046ae)
2013-10-22 11:11:54 -04:00
Steve Howell 5562f09d99 Add zulip_internal decorator for internal Zulip reports.
(This also ensures that /queries is viewable only from inside
Zulip.)

(imported from commit 697da768889943ab6cea62b3e922cc43afa04759)
2013-10-22 10:15:08 -04:00
Steve Howell 1f4b70938f Add /sent_messages_report to show sent messages per realm per day.
This shows the number of messages sent by users in a realm going
back two weeks.

(imported from commit 9bf677b908f947efef4e00a43d323e1049a9157a)
2013-10-22 10:15:08 -04:00
Tim Abbott cc2284c531 Fix auth checks for IRC mirroring.
There were a couple of bugs in the security checks that resulted in
IRC mirroring of stream messages not working.

(imported from commit 31ac732461a733c1c993f77356053d4f88c67177)
2013-10-21 16:47:40 -04:00
Tim Abbott 1f3278888e get_old_messages: Fix query for the sender narrow operator.
Previously we were having the database do the matching on sender email
address, which resulted in an unnecessary join.

(imported from commit 70bf791a00b7d5965ef977e45b4a0eccbd3402a0)
2013-10-21 16:00:24 -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 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
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
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 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
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
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 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
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 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
Steve Howell b7eba8fe5c Test unread.update_unread_subjects() more thoroughly.
(imported from commit 5f1bbdbc6822615d487404930f5e50c970536761)
2013-10-15 14:57:38 -04:00
Steve Howell 7076258b15 Get stream_data.js to 100% branch coverage
(imported from commit fa1fa18271ba280d819bcec8cdea6337230f1953)
2013-10-15 14:57:38 -04:00
Steve Howell 8cc82c6cbe Optimize /json/update_message_flags.
I added filter() statements to do_update_message_flags().

Here is some context:

Steve Howell: Case 1, have AND clause to reduce work for DB.

humbug=> update zerver_usermessage set flags = (flags & ~1) where id > 9000;
UPDATE 382
humbug=> select count(*) from zerver_usermessage where (flags & 1) = 0;
 count
-------
   382
(1 row)

humbug=> explain analyze update zerver_usermessage set flags = (flags | 1) where (flags & 1) = 0;
                                                       QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
 Update on zerver_usermessage  (cost=0.00..266.85 rows=47 width=27) (actual time=5.727..5.727 rows=0 loops=1)
   ->  Seq Scan on zerver_usermessage  (cost=0.00..266.85 rows=47 width=27) (actual time=0.045..2.751 rows=382 loops=1)
         Filter: ((flags & 1::bigint) = 0)
         Rows Removed by Filter: 9000
 Total runtime: 5.759 ms
(5 rows)

humbug=> select count(*) from zerver_usermessage where (flags & 1) = 0;
 count
-------
     0
(1 row)
Leo Franchi: Sounds reasonable, but I know way less than zev about DBs so I'll defer to his judgement :)

Steve Howell: Case 2, how the code works now:

humbug=> update zerver_usermessage set flags = (flags & ~1) where id > 9000;
UPDATE 382
humbug=> select count(*) from zerver_usermessage where (flags & 1) = 0;
 count
-------
   382
(1 row)

humbug=> explain analyze update zerver_usermessage set flags = (flags | 1);
                                                        QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------
 Update on zerver_usermessage  (cost=0.00..243.28 rows=9382 width=27) (actual time=362.075..362.075 rows=0 loops=1)
   ->  Seq Scan on zerver_usermessage  (cost=0.00..243.28 rows=9382 width=27) (actual time=0.008..6.138 rows=9382 loops=1)
 Total runtime: 362.105 ms
(3 rows)

humbug=> select count(*) from zerver_usermessage where (flags & 1) = 0;
 count
-------
     0
(1 row)
Steve Howell: In both trials, we set it up so that only 382 of 9382 rows need to be updated. The first trial runs about 63x as fast. The second trial, if my theory is correct, is doing 24x as many writes as it needs. Both trials are reading all 9382 rows.

Steve Howell: The expense of the update statement seems to be proportional to the number of rows you "update", not the number of rows that you actually change.

Steve Howell: For now I created #1869.

Zev Benjamin: That sounds like a reasonable explanation. The disk IO can be expensive

(imported from commit d9090daee1f81cad76c430de0956f9bd504da075)
2013-10-15 11:30:13 -04:00
Leo Franchi 6e1bc06323 Fix test to check for new 60-char stream name length limit
(imported from commit 16474a9befc7466ee69f9aef37ec6e52758b5d76)
2013-10-15 10:24:07 -04:00
Tim Abbott 32861af323 [schema] Increase maximum stream name length to 60.
(imported from commit 83e9434178909d18481692a9e7fe3b8e1802bd7e)
2013-10-15 09:13:35 -04:00
Zev Benjamin 4921166b56 Remove rogue print statement
(imported from commit ef0b8855e94cd5e3ec9c80bac8cd82be0ca7911e)
2013-10-11 22:19:35 -04:00
Steve Howell 3ca1ef9a0a Use custom titles for the activity report.
(imported from commit ed991108715d043d5d21d8e9f7573eaedb21fec1)
2013-10-11 16:29:26 -04:00
Steve Howell 8aaff7c772 Show hours per user in activity report
(imported from commit b2932d725b9886ce962cc8ff0dd7073a0265a46c)
2013-10-11 15:44:42 -04:00
Steve Howell f0512e91e0 Split out bot counts
(imported from commit 2e5afae98a28774f555c45019ebbba778160962b)
2013-10-11 15:32:30 -04:00
Steve Howell 276e14e06a Use Hours, not Minutes, on the activity report.
(imported from commit abe1eb306b6505d61671d526bac7bc116caeba1f)
2013-10-11 15:22:16 -04:00
Steve Howell 15fb787583 Filter out Zulip/customer4.invalid from /activity.
(imported from commit 019fdba8275da573fc9c759625ff665961067b63)
2013-10-11 15:15:26 -04:00
acrefoot d2b8fe6f57 fix earlier 'linter workaround'
(imported from commit 4ac9f1e57a241f95f53fa65d82c376a61de2c28c)
2013-10-11 11:54:05 -04:00
acrefoot 98897fe5e3 Queue the day 1 and day 2 Zulip followup emails
Handled by the queue processor for signups. Added a management command
that accomplishes the same task, in case it's needed for manually added users,
or in case we goof and need to remove queued emails for a given user.

This addresses Trac #1807

(imported from commit 6727b82a07fa6a3ea3d827860c9e60fd0602297a)
2013-10-10 19:32:21 -04:00
acrefoot f8662c16f7 Add Mandrill decorators, credentials, actions
You can queue email for future delivery or send immediately via mandrill now

(imported from commit e6b6d11a2d94fcdeaffab80793e7ba31955b9031)
2013-10-10 19:32:21 -04:00
acrefoot 851a6e391e change variable name to get linter to stop complaining
(imported from commit b61824c16b1e7ad88375eeebdd945827dfc7fd3c)
2013-10-10 19:24:50 -04:00
Leo Franchi 1f89bf386f Parse markdown tables and show them with some styling
(imported from commit fb3c599b1dbaed2447f1e710ed7202486000ca2a)
2013-10-10 16:39:11 -04:00
Luke Faraone 1d9391e867 Initial local server configuration.
(imported from commit ac9b9896b74b78c6ca03af7f411d0788ae402cff)
2013-10-10 14:14:14 -04:00
Leo Franchi 6e188fb067 Tweak alert_word matches and add some more tests
(imported from commit 63dc4064c15d5d33a7ec0c992b183bf323dd4ee8)
2013-10-10 10:58:21 -04:00
Leo Franchi 08ae641dd2 Pre-fetch data from the DB and hand to markdown thread
We want to avoid opening a DB connection in the markdown thread
as its DB connection might live for a long time

(imported from commit 7700b2ca793ee5e9add7f071b92f22a4bf576b3d)
2013-10-10 10:58:21 -04:00
Zev Benjamin 2c4a1912e8 Fix parameters for on_close callback
Some of the older documentation was apparently wrong.

(imported from commit 9ebf9d1a72c8b230563f1883d63c26212eb80e22)
2013-10-09 10:45:38 -04:00
Tim Abbott 1a7ddd9ea3 Fix UserActivityInterval overlap bug.
The previous version was incorrect in the event that log_time >
last.start + 15.

(imported from commit 56aa619e8c86db1796cf936c2be5224a25ca2e1f)
2013-10-08 17:21:59 -04:00
Jessica McKellar 3b7143d3ec Linkify narrows in missed message emails.
This will hopefully incentivize people to click one and get back into
the app.

We'll also need this for digest emails.

(imported from commit 57191c3fcca3b12df93a81e4692bb7eb8ccc83b2)
2013-10-08 10:46:52 -04:00
Jessica McKellar 836f3894fb Add a comment to UserProfile that pointer is a Message.id.
And NOT a UserMessage.id. I kept having to trace the code and convince
myself of this.

(imported from commit 720a982a888dd525e63c37ddfedd28b71492d32e)
2013-10-08 10:46:52 -04:00
Tim Abbott f3fd1a2c44 [manual] puppet: Rename humbug user to zulip.
(imported from commit 90e517a4a657d2821b371c833e557c2003c9340c)
2013-10-08 08:57:30 -04:00
Tim Abbott 70c666c3c6 [manual] Rename humbug@humbughq.com to zulip@zulip.com.
This requires renaming the account in Google Apps at the time we
deploy this; we'll probably want to do this during off hours to avoid
any user-visible downtime.

This also updates some related email addresses.

(imported from commit fce7629b359a4f278bbf7815c8d177a8fa0484fe)
2013-10-08 08:57:29 -04:00
Tim Abbott b8b0eb4508 Some zulip => humbug updates in comments and print statements.
(imported from commit 9253569a1df7f96fda81ab162d710cdda03f30ca)
2013-10-08 08:57:29 -04:00
Tim Abbott e11ae77ba6 [manual] Rename /home/humbug to /home/zulip.
This may require just doing an mv on the home directory, plus changing
the home directory in /etc/passwd.  It should of course be done carefully.

(imported from commit 660997d897ee6d33563af74f0fc5d4267a911755)
2013-10-08 08:57:29 -04:00
Tim Abbott 9677ce8920 [manual] Move git checkouts from /home/humbug/humbug to /home/humbug/zulip.
(imported from commit d58be28e57fcb3b5585c0018f1dbb53adf5067df)
2013-10-08 08:57:28 -04:00
Leo Franchi b1a38d751c Hoist variable declaration out of loop
(imported from commit 12d3ea280b4e089a829ba0a557c7803b2db1b15e)
2013-10-07 15:46:13 -04:00
Leo Franchi 72c7c5b836 [schema] Give new realms a default notifications stream, and send signups/creations to it
(imported from commit 19ad761f7d9eabb865ac3526bf66dff8b7ed0224)
2013-10-07 15:46:13 -04:00
Leo Franchi 51e0bea608 Autocomplete emails in sender: completion
(imported from commit 44dc337842d46349b103cf9631faa7d439be682c)
2013-10-07 14:55:58 -04:00
Leo Franchi f0f4ff61f0 Attempt to convert JIRA mentions to Zulip mentions
(imported from commit 0d763c8fdefd8cc2c2ae527fdb80e66635ded3d6)
2013-10-07 13:59:36 -04:00
Leo Franchi 02a48e94f0 Turn JIRA users into mentions where possible
(imported from commit faddc2127fe3fdb95e278df06a834cda700b97f4)
2013-10-07 13:59:36 -04:00
Tim Abbott d188d829d7 Update UserActivity queries for monitoring Zephyr mirroring.
(imported from commit 04a9536da2891e905c6e14e0d452ca62d632641d)
2013-10-04 16:15:53 -04:00
Zev Benjamin 4129541206 github: Add support for commit comments
(imported from commit 43abd740e563952d1291939e6a530b8366232eb3)
2013-10-04 15:53:21 -04:00
Steve Howell 95321a9845 Clean up a few @slow decorators in tests.py.
A few "slow" tests aren't as slow any more, for whatever reason,
so we're setting a higher bar going forward.

(imported from commit 642137cebb7826f4512b5635da9d7b75bd5c35f4)
2013-10-04 00:25:49 -04:00
Zev Benjamin 87daa8d5ef Disable all github notifications except for pull requests for customer37.invalid
(imported from commit bbfe47f4c463516f1e962291bc50ec79c5b2afb5)
2013-10-03 18:48:51 -04:00
Kevin Mehall 72a0b67c80 Prevent other markdown operators from touching URLs.
The text of manual links are already AtomicStrings, so linkified strings
should be too.

Moves emoji detection to happen after linkification, so the emoji rule
won't look at links.

(imported from commit 9c56bce6a0e873b398255e0762dfb312a4a9a64e)
2013-10-03 17:26:47 -04:00
Kevin Mehall 8842349629 Fix links with invalid emoji in them.
InlinePatterns should return None on failure, not text that may
have placeholders in it.

(imported from commit f9d8d22b2b8cfa7a92ecf3e52a6c76b48e6f0175)
2013-10-03 17:26:47 -04:00
Leo Franchi 7da3084465 Use name attribute in dictionary not property lookup
(imported from commit b2adae82f31b57d4e9e049225a662851b4364789)
2013-10-03 16:59:50 -04:00
Steve Howell 35fce47088 Do not embed the API key in webhook error messages
(imported from commit 12d782b1bde2c9f928e509bd6dd0ae9106616ed6)
2013-10-03 14:38:37 -04:00
Steve Howell 05178349a2 Have rest_dispatch() use name of target function for logging.
We want the UserActivity.query field to reflect the name of the
function for REST calls, not the URL, and we accomplish this by
setting request._query to target_function.__name__.

(imported from commit 9df05fef0dffb34483b182b95f8cbc4409083eed)
2013-10-03 14:23:02 -04:00
Steve Howell 97adbedfca Support request._query in update_user_activity().
If request._query is set in the call to update_user_activity(),
we will use that instead of request.META['PATH_INFO'] for
the query field of the UserActivity row we write.

(imported from commit fcee30098e1c7c5cb4195a1e5905fc7b88af804f)
2013-10-03 14:23:02 -04:00
Steve Howell cab71ab3f9 Apply @api_key_only_webhook_view to api_newrelic_webhook.
This makes the code save UserActivity records for this action.

(imported from commit 1ca37d2ba67b2c0e502fc567f80ebda918adc909)
2013-10-03 14:23:02 -04:00
Steve Howell c990d942ac Apply @api_key_only_webhook_view to api_pivotal_webhook.
This makes the code save UserActivity records for this action.

(imported from commit d11267ad3913a4dfe90ad7bd8b30704c7ddb7cb3)
2013-10-03 14:23:01 -04:00
Steve Howell 1c46eca0ef Apply @api_key_only_webhook_view to api_jira_webhook.
This results in some small behavior changes.  First, if a user
has both malformed JSON and an invalid API key, they will now
be informed of the invalid API key, not the malformed JSON,
because the decorator wrapping code executing first.  Second,
we call process_client(), which basically builds us a
UserActivity record with the client "API".

(imported from commit fadb523db9bdc82984bdae61833c5c99f1ebd1c0)
2013-10-03 14:23:01 -04:00
Steve Howell 8a4a069703 Add api_key_only_webhook_view decorator.
This is for webhook API endpoints that only get passed in an api_key,
not an email.  An example would be api_jira_webhook, and some of
the code is borrowed from there.  The rest of the code is from
authenticated_api_view().

(imported from commit b5b2a4ea52f9b317f00357ef3142c76534fabf20)
2013-10-03 14:22:49 -04:00
Steve Howell f6794ce849 Remove stray print statement in tests.py
(imported from commit 2be8ceb83664cfb9f3158e23894637ac513efa41)
2013-10-03 13:03:33 -04:00
Steve Howell d9afabdf6c Add totals row to the main /activity tab.
(imported from commit 9ab25b8fe3018d6f0b31c65494e0132ca997ca9b)
2013-10-03 09:33:51 -04:00
Steve Howell a51f7949b7 Add minutes column to the main Activity tab.
Add the number of person-minutes for the last 24 hours to the
realm report on the main tab of /activity.

(imported from commit 2ff46eacc4c8276ab0407fc6ff9f28f5137f1ed2)
2013-10-03 09:33:51 -04:00
Tim Abbott 3422b02e52 Add some unit tests for gather_subscriptions.
(imported from commit 10c362e36e2e9044918e22449b6d82acb9c867f3)
2013-10-02 16:37:56 -04:00
Tim Abbott 4ae2ae5005 gather_subscriptions: Avoid fetching full stream objects.
(imported from commit 3052dd9c1df050e217949d36259416bc38469674)
2013-10-02 16:15:25 -04:00