Commit Graph

836 Commits

Author SHA1 Message Date
Leo Franchi 8dd4bf8f00 [puppet] Log endtoend send time on a per-realm basis as well as aggregate
(imported from commit 07226b20081d203af1f52776475228d9b6783869)
2013-11-06 11:25:00 -05:00
Jessica McKellar 74d1a56c68 Do not notify on stream messages by default for CUSTOMER19.
(imported from commit 7f737b9068ec39fc53678aa5c0976d3da908ce00)
2013-11-06 10:40:28 -05:00
Luke Faraone 3daca0ca9c Fix rebasing errors that rightfully made the linter sad
(imported from commit fbed798c7d752ea2b058aeebb5ae31a620684a3a)
2013-11-05 17:52:53 -05:00
Leo Franchi 980dc8345a Strip unicode chars from statsd path
(imported from commit 1c5829be7f89ad1e26be52b416a51da63e2a94cf)
2013-11-05 17:47:15 -05:00
Luke Faraone 00e72cd97d Switch url parameter to full_name from service-specific gafyd_name
(imported from commit 21541da29d2846cfd912d19b73e239e96606f9e5)
2013-11-05 16:17:06 -05:00
Luke Faraone c11b65590b SSO / REMOTE_USER support
(imported from commit 4f4fad7af5d3c6099cac95d7708338c182626d72)
2013-11-05 16:14:13 -05:00
Luke Faraone b4ad8d2a5a Factor out Google Apps user-not-registered logic
(imported from commit ba1d9da60df01f063cbfc0374130b655b7555b4a)
2013-11-05 16:14:13 -05:00
Steve Howell 5ff6bc7330 Move activity reports to zilencer.
This commit moves the view code and the URLs.  It doesn't touch
the templates yet.

(imported from commit dbef5eafe4956b29154c1134c05aa586c9e417b2)
2013-11-05 15:41:03 -05:00
Steve Howell 4fb4e04501 Add activity.full_huddle_name().
(imported from commit 304e47ac88d7497fcde49f448912a2e063dd0bd1)
2013-11-05 15:34:29 -05:00
Steve Howell e628efff6c Fix people_dict in activity.js tests.
The simulated people_dict in the activity.js test was not
matching the production code, and going forward, we'll want to
share the people_dict setup for all of our tests.

(imported from commit fc21a02216b9422130b9fe9c11bcf80590612844)
2013-11-05 15:34:28 -05:00
Steve Howell 6d511486cb Add activity.process_loaded_messages() and get_huddles().
Activity.js now has the capability to track huddles that
come through in loaded messages and return them in reverse
chronological order by their most recent message.  Right
now this only connected to a unit test, not any production
code.

(imported from commit 59957086fa2e454e5711472df091f178217aed2b)
2013-11-05 15:34:28 -05:00
Tim Abbott e06722657a [manual] Remove /messages/latest API and related legacy code.
This requires doing a puppet apply on our servers to take effect
properly.

(imported from commit 19dc56f071f07a5d2571eef49dd835121b2e82b6)
2013-11-05 14:19:40 -05:00
Leo Franchi 2551968966 Log end-to-end send time to statsd
(imported from commit 5a085b2cc72eaa69ca5dd704e3b33df895144b95)
2013-11-05 11:47:48 -05:00
Steve Howell d0722b6962 Remove dead code related to /activity.
(imported from commit ebec4ddb8727c16dc04ebd32829389e5594d49f5)
2013-11-05 11:00:59 -05:00
Steve Howell bd84d1305e Clean up titles in activity reports.
(imported from commit e516bbfaff7b3615059b4aafb3304e31db85edcc)
2013-11-05 08:13:00 -05:00
Steve Howell 23cd4016f4 Look for send_messages_backend in /activity page.
The main Activity page counts users as active if they have either
sent a message or updated a pointer.  In the unlikely event that
somebody sent a message but never updated their pointer, we were
undercounting them, if they went through send_messages_backend.

(imported from commit 5f112be87a239980c38a18c13f9cd68e90d2e905)
2013-11-05 08:12:59 -05:00
Tim Abbott 792b283dcd Report end-to-end sending times as experienced by clients.
This should help with determining the prevalence of slow sends as
experienced by users.

(imported from commit f00797679315c928af3c87ad8fdf0112f1dfa900)
2013-11-04 18:32:34 -05:00
Leo Franchi 0bcc8db924 Give the initial bots themselves as owners
(imported from commit aca5565a3705aa6c6d55eb8afb5ca84f0efc9a0c)
2013-11-04 17:36:14 -05:00
Tim Abbott 97e9615921 Add script to replace populate_db for local server.
(imported from commit ca51391fc1d8ed13c0fcd36e17c875a085c78eb0)
2013-11-04 17:01:41 -05:00
Leo Franchi 6765ec0795 Use a site-specific Zulip Admin email in django error pages
(imported from commit 2d5415d7cd81befc3051b5de3835c0cd258b6375)
2013-11-04 16:35:50 -05:00
Tim Abbott 87271b57cd Fix feedback check to correctly use the recipients list.
Even for a PM, the "recipients" list is 2 people -- the sender and the
receiver.

(imported from commit 5503e0ee2abb643601a0a4e61366127914808245)
2013-11-04 12:58:40 -05:00
Leo Franchi fe1313ad76 Split management commands for internal use into zilencer/
(imported from commit 3fd81bfc7e987fc88bd1d632546850eebbb92234)
2013-11-04 11:58:52 -05:00
Tim Abbott 54871853b1 Remove obsolete Tornado-internal user pointer cache.
It is from before we were caching UserProfile objects.

(imported from commit 5335728bf0c62efb330fa29a6e08efc43eb86691)
2013-11-04 11:51:18 -05:00
Tim Abbott 2a77cecc7a Remove several unnecessary TODO notes.
(imported from commit 1292d048d63c056af69f62352cf8cab283ef5792)
2013-11-04 11:51:18 -05:00
Tim Abbott 68dcc760c3 Clean up some unused imports.
(imported from commit 0c5d8e2a55ba1b8909ba807fee3afe863dcdc226)
2013-11-04 11:51:17 -05:00
Steve Howell 0c505c9b80 Exclude "desktop" from Client tab of /realm_activity.
The "desktop" counts aggregate all desktop clients, but on the
Clients tab, we are only interested in specific versions.

(imported from commit eea2d8da584a6fa32fa1f3a2bae71ef5daaba738)
2013-11-04 10:24:55 -05:00
Steve Howell 7a67fb34b0 Rename: queue_followup_emails -> enqueue_followup_emails.
(imported from commit c44e790de5b694f8d98b03608231f7a284856254)
2013-11-04 10:20:59 -05:00
Steve Howell c4141eeeb0 Rename: queue_digest_emails -> enqueue_digest_emails.
(imported from commit a72fdf849814ff974117c55bf1b155c494a1b160)
2013-11-04 10:20:59 -05:00
Tim Abbott 03c5ae44a4 Remove unnecessary transaction in message flag updating.
We only needed a transaction here to workaround problems associated
with not having database-level autocommit.

(imported from commit 240ba05a4a4a846a7ff62e6e59e403ab0d78ab11)
2013-11-04 07:31:39 -05:00
Tim Abbott 0ae03eb655 Remove transaction management hacks in get_client.
I'm pretty sure this code was a hack to workaround the fact that
without database-level autocommit, .get_or_create is racy.

(imported from commit bfdd476a354aee439feeaa0030ae59cc43c165b9)
2013-11-04 07:31:39 -05:00
Tim Abbott 29aef33c53 Remove transaction management hacks in workers.
(imported from commit 33b9349bd139907755b52474df8a0da13b73b80d)
2013-11-04 07:31:39 -05:00
Tim Abbott 2de31ee287 [schema] Remove the UserMessage.archived field.
This was a precursor to UserMessage.flags.read that never got used
because we decided to use django-bitfield.

(imported from commit 868754723c07ee9b85ae951aee785e571ccfef97)
2013-11-04 07:31:11 -05:00
Steve Howell 0e0272220b Ignore internal records in /realm_activity.
(imported from commit ba0387cefe53d3a766f539cabdc1252b2d749839)
2013-11-02 17:58:34 -04:00
Steve Howell 54a25b065a Add show_admins management command.
(imported from commit f16e118fa5203408b99f0a41ff7cecbffb821fa7)
2013-11-02 11:37:27 -04:00
Steve Howell 406c4f172a Add realm.get_admin_users() method.
(imported from commit b1cb465f0c81eb9f56ad1486b92cd39a8d001474)
2013-11-02 11:37:27 -04:00
Steve Howell f71fa2eef1 Add History tab to /realm_activity
(imported from commit 1c308fc46031f68441a6cfba293a45655959cb7e)
2013-11-01 18:13:16 -04:00
Steve Howell 33c7ec4215 Add Clients tab to /realm_activity.
(imported from commit c443ae6494584280dca21b3487aeba3a2e79643a)
2013-11-01 18:13:15 -04:00
Steve Howell a6383a881f Split out bots on /realm_activity.
(imported from commit 5962646f4d76c95078a24de7fc22334597ff206f)
2013-11-01 18:13:15 -04:00
Leo Franchi ca8187b8cf Email gateway bot variable name changed to EMAIL_GATEWAY_BOT
(imported from commit 01c430bd9b916c9bb152ee821214495333f1d37e)
2013-11-01 16:46:17 -04:00
Steve Howell 49e26deaa1 Add Name column to /realm_activity.
(imported from commit ed8d1a775f67ec967555a03d9be14bfc02273808)
2013-11-01 15:42:29 -04:00
Steve Howell 2e2a4d8fb5 Treat more activity as "send" activity.
(imported from commit 18c26ac5dd9a1766e3ed02bf63ae0be31898524d)
2013-11-01 14:59:14 -04:00
Steve Howell e65139b5a4 Add "Total sent" column to /realm_activity.
(imported from commit 1623f01ee18317af3e9af5359e089b4c9a1c64f4)
2013-11-01 14:59:14 -04:00
Steve Howell 0ca84ea981 Use better date format in activity reports.
(imported from commit 5114cdcaaf5bddb4578246b9c12163d0ba1fad45)
2013-11-01 14:51:36 -04:00
Steve Howell 80f9ae7514 Change column labels in /realm_activity.
(imported from commit 3435eebaefe46ff99a127a6834669b4be3186d8f)
2013-11-01 14:51:36 -04:00
Leo Franchi db6550e99a Make built-in bots come from settings.py, and allow localserver-specific ones
(imported from commit e21933e37487314ac986147562817a19227e8960)
2013-11-01 14:13:05 -04:00
Steve Howell 6382c417cf Improve zulip_internal decorator.
I added the @wraps decorator, and I point request._query at the
function name to override the URL, since some of the internal
URLs have realm names and domain names in them.  I basically
prefer the function names in most cases, so I just made this
automatic for zulip_internal functions, rather than having to
remember to address URL-vs.-function-name for every new endpoint.

(imported from commit 5583607f395be4dfae0bac31e1cdbffdf51fb3e8)
2013-11-01 13:43:38 -04:00
Steve Howell 8bbc9e886e Add Desktop/iPhone/Android columns to /realm_activity.
(imported from commit b10916f5d63dabcb079f835af7f2829b266a924a)
2013-11-01 13:21:58 -04:00
Steve Howell 4f788067cc Add "Use" column to /realm_activity.
(imported from commit d8f431b108c8d3846e00c47859004e952f7de422)
2013-11-01 12:51:45 -04:00
Steve Howell b72eb72edb Make emails linkable in /realm_activity.
(imported from commit c8e721b5a6b03bbddd86f24ec60bd750aee33323)
2013-11-01 12:51:44 -04:00
Steve Howell 73c5dfb454 Improve column headers for /realm_activity.
(imported from commit 703ef40ca0d177062b28ccd2802c7e690189ce2d)
2013-11-01 12:51:44 -04:00
Steve Howell 95dc0894d8 Add /realm_activity report.
This report will eventually replace the per-realm report that is
now accessible through /activity.  In order not to disrupt Waseem,
I'm leaving the old reports around until we've polished the new
ones.

The old report does 24 different queries to get per-realm user data.
The new approach gets all the data at once, and it slices and dices
the data in Python to accomodate our slightly quirky data model.

On localhost, this is a typical query:

LOG:  duration: 5.668 ms  statement: SELECT "zerver_useractivity"."id", "zerver_useractivity"."user_profile_id", "zerver_useractivity"."client_id", "zerver_useractivity"."query", "zerver_useractivity"."count", "zerver_useractivity"."last_visit", "zerver_userprofile"."id", "zerver_userprofile"."email", "zerver_client"."id", "zerver_client"."name" FROM "zerver_useractivity" INNER JOIN "zerver_userprofile" ON ("zerver_useractivity"."user_profile_id" = "zerver_userprofile"."id") INNER JOIN "zerver_realm" ON ("zerver_userprofile"."realm_id" = "zerver_realm"."id") INNER JOIN "zerver_client" ON ("zerver_useractivity"."client_id" = "zerver_client"."id") WHERE "zerver_realm"."domain" = 'zulip.com'  ORDER BY "zerver_userprofile"."email" ASC, "zerver_useractivity"."last_visit" DESC

(imported from commit 0c71f4e32fe5a40f4496749dc29ad3463868d55e)
2013-11-01 11:46:26 -04:00
Steve Howell 3577ba7585 Add /user_activity page.
This page shows aggregate activity for a user on various
clients.  This allows Waseem to troubleshoot things like users
switching between website and desktop, etc.

This particular page probably won't be used too much, but some of the
logic is gonna be reused in the per-realm activity pages.

(imported from commit b8c1fad5bfa45daab40954f92319f6f89a3fa433)
2013-11-01 11:46:26 -04:00
Tim Abbott ddbfe31449 Remove obsolete management command for mit.edufullname transition.
(imported from commit aed2a2d7bfedd98e2406bb18bf54f953a5ae7ef3)
2013-11-01 10:30:17 -04:00
Tim Abbott 11b92534e8 Remove obsolete management command for unread counts transition.
(imported from commit 52c6acbf4e8e53f86e880e475396d824c729405f)
2013-11-01 10:30:17 -04:00
Jessica McKellar 35e764e7d1 integration: add branch name to Stash messages.
(imported from commit 3421717acd0e85cb2a1b1f0bd15438f70fd3d82e)
2013-11-01 10:10:17 -04:00
Jessica McKellar 8684c98eef tests: add basic navigation Casper tests.
(imported from commit 66ebb76123213167e551fb0d776a824e218a9032)
2013-10-31 17:34:34 -04:00
Jessica McKellar b4d115f902 GitHub integration: only report pull requests for CUSTOMER38.
(imported from commit 4f253d544843b97f5faa64dcf8843498603f5a11)
2013-10-31 17:16:07 -04:00
Tim Abbott 429c41da79 Rename client-activity to client_activity to match other management commands.
(imported from commit b0b2cd372810923b3c808142f7b7eeef285d132d)
2013-10-31 15:29:50 -04:00
Tim Abbott dbd4c187e3 Rename create-stream to create_stream to match other management commands.
(imported from commit 28daad12943ab5eb245d7737934b08f5b29e8f90)
2013-10-31 15:29:50 -04:00
Tim Abbott 5b1e504e13 Rename rename-stream to rename_stream to match other management commands.
(imported from commit 28522ac669a38e3de3f25b28c82ab0c787aecd0b)
2013-10-31 15:29:50 -04:00
Tim Abbott 013e84ef86 Remove obsolete explain_js_error management command.
(imported from commit 92f23e3bb7e6dbbad5162446b5f19e74728cf608)
2013-10-31 15:29:50 -04:00
Tim Abbott 217478e988 Remove obsolete clear_db management command.
do_destroy_rebuild_database is the "new" way to reset one's dev
database.

(imported from commit 8edb707ecd5e6e24b62eef324915cc3a4a5b8eda)
2013-10-31 15:29:50 -04:00
Tim Abbott 384f64d38d Remove obsolete management commands from various field additions.
(imported from commit b44a2b683768c790839e82e2e9c9a18827670113)
2013-10-31 15:29:50 -04:00
Tim Abbott f0580dd28c Remove obsolete management command for activating MIT users.
(imported from commit a965eea8edfc9d73a00770d85cd517343f607338)
2013-10-31 15:29:50 -04:00
Tim Abbott 06d43a6f97 Remove obsolete management commands from the stream color transition.
(imported from commit d6d508d952714a1865ca4fddcb48d0ccedb6f4dd)
2013-10-31 15:29:50 -04:00
Tim Abbott 6d8fc371fb Remove obsolete command to delete tutorial streams.
We don't have tutorial-bot anymore, so this is no longer needed.

(imported from commit b8a1bc9c2379a451e8cc1ed43b15f373bb3f2b06)
2013-10-31 15:29:50 -04:00
Tim Abbott c8d07cc64c Remove management commands from the mysql=>postgres migration.
(imported from commit 636f71b435a50e83fd8a9e40685d7c52b3b01f30)
2013-10-31 15:29:49 -04:00
Kevin Mehall c56110dd7b Add /user_uploads parameter to return the link instead of redirecting.
(imported from commit 305e201e01aa919d2732dba3f1fd94ec4501d713)
2013-10-31 14:36:35 -04:00
Kevin Mehall a09c7e1e0c Make rest_dispatch errors cleaner for requests from browsers.
If you don't have a cookie or basic auth and the request looks like
a top-level page in the browser, redirect to the login page.

(imported from commit fc1bcb1080591522bd1b694664255f7049a5d443)
2013-10-31 14:36:34 -04:00
Waseem Daher 1d784801cf More settings.LOCALSERVER -> settings.LOCAL_SERVER.
(imported from commit 2b5045d302b8ebb2a5c7175264b4ab9cfef2844d)
2013-10-31 13:31:03 -04:00
Steve Howell 70c1c31b3a Simplify callback protocol for register_json_consumer().
The register_json_consumer() function now expects its callback
function to accept a single argument, which is the payload, as
none of the callbacks cared about channel, method, and properties.

This change breaks down as follows:

    * A couple test stubs and subclasses were simplified.
    * All the consume() and consume_wrapper() functions in
      queue_processors.py were simplified.
    * Two callbacks via runtornado.py were simplified.  One
      of the callbacks was socket.respond_send_message, which
      had an additional caller, i.e. not register_json_consumer()
      calling back to it, and the caller was simplified not
      to pass None for the three removed arguments.

(imported from commit 792316e20be619458dd5036745233f37e6ffcf43)
2013-10-31 13:18:11 -04:00
Jessica McKellar f1e90086f5 Remove the onboarding checklist.
Looking at the historical data, fewer than 50% of active users have
completed the checklist, which means that it is just persistent
clutter. We also have other better ways of encouraging people to send
traffic and get the apps now.

This commit removes both the frontend UI and backend work but leaves
the db row for now for the historical data.

(imported from commit e8f5780be37bbc75f794fb118e4dd41d8811f2bf)
2013-10-31 11:34:15 -04:00
Tim Abbott 020bd9d4e9 signups: Don't count bots when reporting the number of users in realm.
(imported from commit 124b1baa76c1425824610679747e6576df55d189)
2013-10-30 20:39:40 -04:00
Tim Abbott a788992f67 signups: Cleanup unnecessary database query.
(imported from commit 8d248999d8f02378fd44ce740ec6bad104745891)
2013-10-30 20:39:40 -04:00
Steve Howell ddc7608afe Add enqueue_file management command.
This reads lines from a file and pushes them on to one of our
worker queues.

(imported from commit 2ed3338c5065819f8bafb247a15799e2bc9e7d39)
2013-10-30 16:47:16 -04:00
Steve Howell d7d1888ce0 Add TestWorker queue processor.
TestWorker is for troubleshooting, and it simply appends lines to a file
in /tmp.

(imported from commit 96b646a193a5474f3222b41725742e359b5301ec)
2013-10-30 16:47:16 -04:00
Waseem Daher db1f5065a7 Add tooltip for, e.g. !gravatar(wdaher@zulip.com) output.
(imported from commit eff24a2fc7da77edc26449074acf75832d368a17)
2013-10-30 13:29:37 -04:00
Luke Faraone ab9b1be82c Rework management commands to handle deployment assignment
We now ensure `create_realm` adds you to a default deployment and that
`create_deployment` removes the old deployment association when
performed.

(imported from commit 5b94fb07b8e11332765b057dc640a5ed873ec99e)
2013-10-30 12:00:13 -04:00
Jessica McKellar 3551b211f2 tests: add missing stash fixture.
(imported from commit 696e789bcab872d570275a64630317af784abb25)
2013-10-29 23:07:07 -04:00
Jessica McKellar 9bf282386d tests: add a Stash test based on the sample JSON.
(imported from commit 8761e4742167197f472c78e6546e8934fdd5ae33)
2013-10-29 22:45:50 -04:00
Jessica McKellar 54977707cf tests: remove redundant http_auth method.
(imported from commit 7fc425ce0e61e68c2fc033c02997ec0786e118fb)
2013-10-29 22:45:29 -04:00
Jessica McKellar 8e838f4db3 Add a first pass at Stash integration via their webhook mechanism.
(imported from commit 6173379f72aeef318550b35e51d4aa1fd69997ed)
2013-10-29 22:40:42 -04:00
Leo Franchi 9be1333c6b Log send_message times through our new socket infrastructure as well
(imported from commit 215be8f7e3d2498ed34e9fcc421498a7cfca4fbc)
2013-10-29 17:49:27 -04:00
Steve Howell 884e602185 [puppet] Handle exceptions from queue workers.
Subclasses of QueueProcessingWorker that don't override start() will
have their consume() functions wrapped by consume_wrapper(), which
will catch exceptions and log data from troublesome events to a log
file.

We need to do a puppet apply to create /var/log/zulip/queue_error.

(imported from commit 3bd7751da5fdef449eeec3f7dd29977df11e2b9c)
2013-10-29 17:45:31 -04:00
Leo Franchi 8e05f76511 Only enable analytics and dropbox on non-LOCAL_SERVER
(imported from commit 1ba877550b3afde51bec6f344762ea998800c5b6)
2013-10-29 17:33:36 -04:00
Tim Abbott 1292c5dbfe Add backend support for Jabber mirroring.
(imported from commit 12f5c708a6961aded4f4e166af84e87720be4ddc)
2013-10-29 16:49:42 -04:00
Kevin Mehall 06590f4332 Upload to local filesystem on local server.
(imported from commit 6c38a8cae721b2e7a0863470692cc56425006ecb)
2013-10-29 16:19:04 -04:00
Kevin Mehall f9af7ad1cf Resize uploaded avatar images
(imported from commit 47ff86fcd47871916631baa34f99bbddb67f87d0)
2013-10-29 11:42:33 -04:00
Steve Howell 0b335a7b73 Simplify DigestWorker.
The DigestWorker isn't do any batching of events, so it can
be implemented with a simple consume() handler.

(imported from commit 0560eaf1a6e510adf97448fbe8933d9903d30016)
2013-10-29 11:39:45 -04:00
Steve Howell 7cf66b5bb8 Allow users to upload avatars on the Settings page.
We were using Gravatar for user avatars, but now users can
upload their avatars directly to Zulip, and we will store
their avatar for them.  This removes the old Gravatar-related
interface and polling code.

This commit does not attempt to update the avatars in
messages that have already been loaded, either for the user
making the change or other users.

(imported from commit 301dc48f96f83de0136c93de57055638c79e0961)
2013-10-29 10:59:41 -04:00
Steve Howell 68942a8f3a Properly split up "Your Account" and "Notifications".
The "Your Account" and "Notifications" boxes on the Settings
page each had their own border and their own "Save changes"
button, but they were within the same form and sending to the
same back end point.

This commit creates a separate form and endpoint for each
of the two boxes.

(imported from commit 04d4d16938f20749a18d2c6887da3ed3cf21ef74)
2013-10-29 10:59:41 -04:00
Leo Franchi a33640c7dd Sleep digest queue worker for 1min between attempts to drain queue
(imported from commit e272dcd33bc89e6813abb0b4dc2c882a8048245e)
2013-10-28 15:47:04 -04:00
Tim Abbott 901a5c342c Use os.path directly rather than sometimes importing it separately.
(imported from commit 48486c4ea64d02a15faeebb0f490d31e9b113d62)
2013-10-28 15:44:13 -04:00
Zev Benjamin 807116e955 Delay connecting to RabbitMQ until it's necessary
Previously we were connecting at import-time.

(imported from commit 9a638f0d238f3b6b00feb4aa524098a64953cb92)
2013-10-28 15:27:25 -04:00
Zev Benjamin ffb6266319 Refuse to run a queue processor if USING_RABBITMQ is False
(imported from commit 39beff47cdbb18ba39756989e6f07facbd16864f)
2013-10-28 14:30:53 -04:00
Zev Benjamin f241897c5b Add function to get the set of active queue processors
(imported from commit 1b9e52cfaf00827305a8f790091860436739d11c)
2013-10-28 14:30:53 -04:00
Zev Benjamin 822edaa890 Condition the registration of some queues on being deployed
This prevents the ones with external side-effects (like sending real
email) from being accidentally run in dev instances.

(imported from commit 6d9861d721abb29136bfff974de01a9264051436)
2013-10-28 14:30:53 -04:00
Zev Benjamin 8aa2c7b547 Make the purge_queue management command more efficient
Before we were removing items individually from the queue.  We now
directly use RabbitMQ's queue purging mechanism.

(imported from commit 62ab52c724c5a221b4c81a967154a4046a579f84)
2013-10-28 14:30:53 -04:00
Leo Franchi e1557bef73 Cache realm user basic info dict that is used in bugdown
(imported from commit 688c47daceb73534be90bd98a031c7b4edb5546e)
2013-10-28 12:59:36 -04:00
Leo Franchi b26f158020 Use user_profile instead of leaked object from list comprehension
(imported from commit 7d8467b104fc80d52fa829eb0ff949b1bd0e578f)
2013-10-28 12:59:36 -04:00
Tim Abbott 56e9ad230e [manual] Move our deployment scripts to scripts/.
This will require updating the post-receive code on git.zulip.net to
work.

(imported from commit 2e51fa2d7b891c1138d3f22ae534cfb8a6cf174c)
2013-10-28 10:54:48 -04:00
Zev Benjamin 7b6f6823a5 [manual] Change references to the humbug user, schema, and database to zulip
This commit must be simultaneously deployed on both staging and
prod0.  It also requires completely taking down the app.

To deploy these changes, do:
* check out this commit at /root/zulip on postgres0, postgres1, staging, and prod0

* stop the process_fts_updates job on postgres0 and postgres1
* stop the app on staging and prod0

* do a puppet apply on postgres0, postgres1, staging, and prod0
* move the new client certificates into place on staging and app
* move the new server certificates into place on postgres0 and postgres1
* reload the database config on postgres0 and postgres1 (this might
  actually require a restart)
* run tools/migrate-db on postgres0 as root

* do a deploy through this commit on staging and prod0
* start the process_fts_updates job on postgres0 and postgres1

* do a puppet apply on nagios

(imported from commit 819bdd14326c1425e2d3041a491a8ca3b9716506)
2013-10-26 04:16:27 -04:00
Steve Howell 13768495a6 Avoid long locks in process missedmessage_emails queue.
(imported from commit aed4a89244dce19085ed2ad89a7539ab297d8bc9)
2013-10-25 20:45:19 -04:00
Steve Howell 3cbb9f6b08 Avoid long locks in process digest_emails queue.
(imported from commit 49c7441463c5e63e52e5b099bd854bd4ae769f13)
2013-10-25 20:34:25 -04:00
Jessica McKellar 2be6c541cf digest emails: use a template filter to format new users, streams, etc.
(imported from commit e61a3dd6753db82da1b30c50e5bbf6273f302645)
2013-10-25 19:11:41 -04:00
Jessica McKellar d4b60e9304 Add a custom template filter for formatting displaying lists of items in emails.
We do this operation several times in the digest e-mails.

(imported from commit 7b906bad582c628d4461637dc7af374df349e09a)
2013-10-25 19:11:40 -04:00
Jessica McKellar a4a12cf407 digest: Add a queue processor that processes digest email requests.
(imported from commit 4f0abb70c92ae6bb47abb3792cca79d3f70e716a)
2013-10-25 19:09:45 -04:00
Jessica McKellar fac9d34d6c digest: Add a management command to enqueue digest email recipients.
(imported from commit 70ff2c7a4dae654f4077041c45e2154b3ac7afb7)
2013-10-25 19:08:47 -04:00
Jessica McKellar 772adc1969 digest: Add functions used to compute interesting traffic.
So far, we gather: "hot conversations", missed PMs, new streams, and
new users.

(imported from commit c3c723d0426cb55bd0e43917c67f93db9052f9ed)
2013-10-25 19:08:46 -04:00
Waseem Daher d44c0d5f5d Pass local_server into page_params.
(imported from commit 50dcee54644e0ee2ad8b13ec12e7134a9ab58d86)
2013-10-25 17:37:42 -04:00
Waseem Daher 66f48288b4 Rename LOCALSERVER -> LOCAL_SERVER.
(imported from commit b3abdd10d54d2ad7a9c463af9a291d2e2127707f)
2013-10-25 17:37:06 -04:00
Leo Franchi c12a97577e Rework local_settings_template.py to be clear about what the user needs to do
(imported from commit f69ea0d57e885509abc70dc4f2bee6e36169691f)
2013-10-25 16:35:27 -04:00
Luke Faraone a1b44986e0 [schema] Add a base_{api,site}_url property to our deployments.
This will allow us to redirect clients to the correct local site.

To apply this migration, just run:
     python manage.py migrate zilencer 0002

(imported from commit 7bd39b5f035145b6b52e1b2cb2ad5f6720d598ce)
2013-10-25 15:18:37 -04:00
Luke Faraone 238d19e1f1 Include a rest_dispatch in tornadoviews and call it from urls.py
(imported from commit aefe66b44be60b39d0f6bb3076502e964f1ed6bd)
2013-10-25 14:13:31 -04:00
Luke Faraone e552307511 Send feedback to a queue to be forwarded to staging.
(imported from commit 4a9a1bfc6c95763a816263a726cc61b3ca90bf15)
2013-10-25 14:13:30 -04:00
Luke Faraone 1fa65915f2 NACK on consumer failure
(imported from commit 1cad1096dd1a969b2551822575784c338a82f433)
2013-10-25 14:13:30 -04:00
Luke Faraone 9d4ef27b97 Make rest_dispatch accept a list of globals and move it into its own file.
We're going to be using this from other views, so make it more generic.

(imported from commit c2c4f64b2a212f8a254f75c21dc93d8fc3f8351a)
2013-10-25 14:13:30 -04:00
Luke Faraone 81d7dd1fda [schema] Support for authenticating Deployments via the API.
Here we introduce a new Django app, zilencer. The intent is to not have
this app enabled on LOCALSERVER instances, and for it to grow to include
all the functionality we want to have in our central server that isn't
relevant for local deployments.

Currently we have to modify functions in zerver/* to match; in the
future, it would be cool to have the relevant shared code broken out
into a separate library.

This commit inclues both the migration to create the models as well as a
data migration that (for non-LOCALSERVER) creates a single default
Deployment for zulip.com.

To apply this migration to your system, run:
   ./manage.py migrate zilencer

(imported from commit 86d5497ac120e03fa7f298a9cc08b192d5939b43)
2013-10-25 14:13:30 -04:00
Luke Faraone 52309b5789 Enable absolute imports for non-third-party code where it was omitted previously
(imported from commit 34856ac32c6b94b614273a6fe46c87a314058d9b)
2013-10-25 14:13:30 -04:00
Luke Faraone 70e161db01 Make settings.LOCALSERVER available as `localserver` inside templates
(imported from commit 4f0cfd1f1015061942f603cbc03a253a713a9f83)
2013-10-25 13:31:13 -04:00
Leo Franchi a9b9c0ec7b Add Email Mirror default settings and error out with readable warning if not configured
(imported from commit adac321d09561b51277ec1e314a1d480dc01e0c8)
2013-10-25 11:51:13 -04:00
Leo Franchi 2d276179d0 Refactor email-mirror to handle running on any machine
(imported from commit 2971449ceaacb564770e66874fc095f77e68d445)
2013-10-25 11:37:34 -04:00
Steve Howell 9979d884e5 Remove 06-unread.js.
This test has been broken for a couple months, and nobody has taken
ownership of fixing it.  It's always slow, sometimes it fails
randomly, sometimes it fails for things that aren't really problems,
and it's generally been way more trouble than it's worth.

(imported from commit 8080e81b226a372e763a2558f4e5668c3a4d087c)
2013-10-25 11:27:25 -04:00
Kevin Mehall 3bad5acc71 Fix upload auth redirect for user_activity.
Use rest_dispatch for upload auth redirect so it doesn't send the
long URL to user_activity.

(imported from commit ab327bbd529412e43eee6d109f8550180544dbbb)
2013-10-24 17:33:12 -04:00
Kevin Mehall 19b9b6e2ec Reduce the length of public upload URLs.
(imported from commit dc4d51da39b218068012ebad57e1f92cb50137c3)
2013-10-24 17:01:06 -04:00
Kevin Mehall 0a271f149b Enable authed file uploads for squarespace
(imported from commit c72e76d27f99cd7610eb6c93b57b8ff727b461a9)
2013-10-24 17:01:06 -04:00
Kevin Mehall 5e1caad88a Show upload filename in tooltip without other ugly parts of the URL.
This works for both public and authenticated uploads.

(imported from commit f9be340b53d0f72bf5b3c31a5d51a1fad80759be)
2013-10-24 17:01:06 -04:00
Kevin Mehall 0a3a22cb3d Support authenticated upload URLs.
Trac #1734

This is implemented by bouncing uploaded file links through a view
that checks authentication and redirects to an expiring S3 URL.

This makes file uploads return a domain-relative URI. The client converts
this to an absolute URI when it's in the composebox, then back to relative
when it's submitted to the server.

We need the relative URI because the same message may be viewed across
{staging,www,zephyr}.zulip.com, which have different cookies.

(imported from commit 33acb2abaa3002325f389d5198fb20ee1b30f5fa)
2013-10-24 17:01:06 -04:00
Kevin Mehall 473a98d0a4 Split out common code for existing and authenticated upload systems.
(imported from commit bf513eaff90ae7c4a0be825317690058f9f54621)
2013-10-24 17:01:06 -04:00
Kevin Mehall fb4eae9e2b Include realm ID in S3 metadata on uploaded files.
(imported from commit 7d41ec94991bd257485116791a0d1ef2c22d9b37)
2013-10-24 17:01:05 -04:00
Kevin Mehall e3b2e7ece2 Allow domain-relative and fragment links
(imported from commit 0a15eeb35ad709977f3b2e6c550c3b78f1b4b402)
2013-10-24 17:01:05 -04:00
Zev Benjamin ec21275b19 Move rabbitmq username into settings.py
(imported from commit f9a8f80f53b8774781b8558444e601567cb59835)
2013-10-24 16:40:38 -04:00
Zev Benjamin 98ec953e2e bitbucket: Include the branch name in the topic
(imported from commit b9074dc509818b4db0c4fa10f6200935c4738b64)
2013-10-24 16:25:23 -04:00
Leo Franchi ae104ace25 Only load APNS cert if it exists
(imported from commit 8505c9a32feb4c7470dfde6c4ceaaa0a8e8f33a1)
2013-10-24 15:55:42 -04:00
Tim Abbott 4b45c8bf96 Fix update_message_flags tests to test with real messages.
As it turns out, some of these tests used message IDs 1 and 2, which
Hamlet didn't even necessarily receive as the messages to update --
which meant that they previously updated 0 messages and returned
success.  So those tests started failing when I added a check for not
updating anything in the update_message_flags backend -- and this
commit fixes the tests to actually update a nonempty set of messages.

(imported from commit 9034b415d4862216a266416a8e509d987050ffd7)
2013-10-24 15:44:17 -04:00
Leo Franchi dc8bfde0b4 Add a check_apns_tokens manage.py command to flush old tokens
(imported from commit 15dcfaa1967bd749b582882c4a816a457ca6cc12)
2013-10-24 14:54:31 -04:00
Leo Franchi 410ee44eb6 Send users push notifications when they miss messages
(imported from commit 6c54fe44a82c5796268e56d3f5577bf4cfc8163a)
2013-10-24 14:54:31 -04:00
Leo Franchi 05564ec0e2 [schema] Add a config option for enabling/disabling push notifications
(imported from commit 5649188cd5e0e4edb6e71559ec7d7fc5e92efaf8)
2013-10-24 14:54:30 -04:00
Leo Franchi 7961d4f6b3 Add a push notification module to handle mobile client notifications
(imported from commit 3061a6e2d845226d3dce5bb262deb3a896e54f07)
2013-10-24 14:54:30 -04:00
Leo Franchi 507a3ecab3 Allow overwriting of APNS as iOS will send it on each startup
(imported from commit 4a22f9f37d550b6c2e06f543434466453e196458)
2013-10-24 14:54:30 -04:00
Leo Franchi 1d82704b8d [schema] Add a last_updated field to AppleDeviceToken
(imported from commit 2ea91e462773c50591585a610b0de63625ad2b7e)
2013-10-24 14:54:30 -04:00
Leo Franchi 13b452ddf8 Add a method=? parameter rest_dispatch to support PATCH-via-POST
(imported from commit 66f7011d6920639abc307ca85708bc958f3bb0e3)
2013-10-24 10:22:06 -04:00
Leo Franchi a2a1867f25 Only render tweets if we have credentials
(imported from commit 46c59f430aeae87a832f33d2ccb85209f9caec74)
2013-10-24 10:19:23 -04:00
Tim Abbott 1b381b343d Allow starring historical messages.
This has a small bug where we don't actually filter the message out of
the home view; fixing that requires adding an index on the "flags"
field of UserMessage.

(imported from commit 492c99d0a8e87b253e577be6564bec12099bd8e9)
2013-10-23 18:51:47 -04:00
Zev Benjamin 89bcabbb65 Disallow XHR streaming when running the test suite
There seems to be some sort of bug involving PhantomJS and XHR
streaming messages.  When successive pages are loaded that use XHR
streaming, PhantomJS seems to think the second one never finishes
loading and therefore hangs.

(imported from commit db93b4cab816f1fdc3f3f543c9394b1cba8abedb)
2013-10-22 18:45:11 -04:00
Zev Benjamin b1eebc0b84 Deliver messages inside Tornado when running tests
This saves us from having to run queue processors while testing.

(imported from commit 927bfa497a47b34603761a148c57d82b2f34f813)
2013-10-22 18:45:11 -04:00
Zev Benjamin a04ac35012 casper: Marginally improve page loaded detection
We really should be setting a variable in Javascript to indicate that
we've finished loading, but this hasn't bitten us yet.

(imported from commit ee1f7c76d9f3c482561cc5c44b81537c7e9636be)
2013-10-22 18:45:11 -04:00
Zev Benjamin 3c73468ba8 Disable unsupported SockJS transports
Because our authentication system reads cookies from the initial
connection attempt, several SockJS transports can't be used.

(imported from commit 34b9571225d39072985b8223fb12c43c7235841f)
2013-10-22 18:45:11 -04:00
Zev Benjamin 5979af3a45 [manual] Add asynchronous message sender via sockjs-tornado
New dependency: sockjs-tornado

One known limitation is that we don't clean up sessions for
non-websockets transports.  This is a bug in Tornado so I'm going to
look at upgrading us to the latest version:
https://github.com/mrjoes/sockjs-tornado/issues/47

(imported from commit 31cdb7596dd5ee094ab006c31757db17dca8899b)
2013-10-22 18:45:11 -04:00
Steve Howell 0662300e9e Remove /json/subscriptions/list endpoint.
(imported from commit db2c38f6b12ebee5250737a6cdd193863a4605af)
2013-10-22 15:51:19 -04:00
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