Commit Graph

277 Commits

Author SHA1 Message Date
Tim Abbott 47b2b1cb1c tornado: Fill the message memcached in a child process.
(imported from commit 3a7b4c0f4aad37319f4cfa7892709e99883f6a87)
2013-01-14 12:28:51 -05:00
Tim Abbott 3b7d61e45f tornado: Get User and UserProfile objects from a memcached.
This commit has the effect of eliminating all of the non-UserActivity
database queries from the Tornado process -- at least in the uncached
case.

This is safe to do, if a bit fragile, since our Tornado code only
accesses these objects (as opposed to their IDs) in a few places that
are all fine with old data, and I don't expect us to add any new ones
soon:

* UserActivity logging, which I plan to move out of Tornado entirely

* Checking whether we're authenticated in our decorators (which could
  be simplified -- the actual security check is just whether the
  Django session object has a particular field)

* Checking the user realm for whether we should sync to the client
  notices about their Zephyr mirror being up to date, which is quite
  static and I think we can move out of this code path.

But implementation constraints around mapping the user_ids to
user_profile_ids mean that it makes sense to get the actual objects
for now.

This code is not what I want to do long-term.  I expect we'll be able
to clean up the dual User/UserProfile nonsense once we integrate the
upcoming Django 1.5 release, with its support for pluggable User
models, and after that I change, I expect it'll be fairly easy to make
the Tornado code only work with the user ID, not the actual objects.

(imported from commit 82e25b62fd0e3af7c86040600c63a4deec7bec06)
2013-01-11 16:11:07 -05:00
Tim Abbott 1a82741650 Move action functions from models.py to zephyr/lib/actions.py.
(imported from commit 9d577dd53ce7d4c9faf6cc8a56129d684a50811b)
2013-01-11 16:11:03 -05:00
Tim Abbott 761b7cd5fa Rename zephyr.lib.time to zephyr.lib.timestamp.
Otherwise one gets:

AttributeError: 'module' object has no attribute 'time'

when trying to use the time module from inside zephyr.lib.

(imported from commit 645368672a3eff68320278dd480edeed56721fcc)
2013-01-11 15:58:19 -05:00
Keegan McAllister 0fdc3b772e runtornado: Print busy percentage at most once every 5s
(imported from commit 017bd01f96689f06c6d166bea47b5112fad05f8c)
2013-01-10 17:21:24 -05:00
Keegan McAllister 1d9bcf8da9 runtornado: Report the percentage of time spent outside the event loop
Note that on local dev servers, this will print out every half second, as
Tornado polls for file changes for autoreloading.  In production it will only
print out when network events occur.

(imported from commit adfe88879e4e446b7dfa6ee69e0a9ad013e9c4d4)
2013-01-10 17:07:46 -05:00
Tim Abbott 3c10a2e6a0 Move bulk_create_* methods to bulk_create.py.
(imported from commit 30d5f86209f9c8807516f0440276fafeb6590c1a)
2013-01-10 16:59:36 -05:00
Keegan McAllister aa1df57163 runtornado: Drop call to tornado.autoreload
tornado.web already does this, based on the setting of the 'debug' kwarg.

Dropping this in production saves us waking up twice a second to stat()
a bunch of files.

We already explicitly restart the server on deploys.

(imported from commit 283bb0da609acb2699a04111a74c13224fe5124c)
2013-01-09 15:50:56 -05:00
Jessica McKellar 95e2948c8a management: add a script to add users in a domain to streams.
(imported from commit e234fe4d283882a5cb2e7a57bcaf8939d973b128)
2013-01-09 11:56:11 -05:00
Tim Abbott 39501e5a78 Make the Django-based test suite much faster.
So, I got annoyed that our test suite was taking forever to run:

real	2m13.443s
user	1m32.630s
sys	0m3.748s

Some quick profiling determined that the test suite is spending all of
its time loading the fixtures files (zephyr/fixtures/messages.json)
that it loads for each test case (3s to load that for each test case).
To improve this situation, I cut out from the test database used by
the test suite most of the users, subscriptions, etc. that aren't
being used directly by the test cases.  The impact is a quite
significant speedup:

real	0m15.176s
user	0m9.161s
sys	0m0.508s

We're still spending over a quarter of a second per test, which isn't
great -- but this is at least no longer unbearable.

This commit doesn't make any changes to the populate_db output if you
don't pass the new --test-suite option.

(imported from commit 2334ba5399b33edab3d29ff269fde4ea77ccd48e)
2013-01-08 17:23:55 -05:00
Tim Abbott 5601086575 populate_db: Remove obsolete mit_subs_list.
(imported from commit 601cde1ae95d3e262be8444ded48f1fdca489f7b)
2013-01-08 17:23:22 -05:00
Tim Abbott 6cd49fbb14 populate_db: Add Humbug error bot.
This is needed to avoid exceptions trying to do internal_send_message
in any test against a simple populate_db database.

(imported from commit 36927f57cbbb7e30ae249b5f1a0549fb352827f5)
2013-01-07 15:06:28 -05:00
Tim Abbott 95f4087a06 Fix dump_pointers on last time.
(imported from commit c16686492e5acd699976268cb48c0290099688cc)
2012-12-15 09:28:22 -05:00
Tim Abbott b2755472bb populate_db: Fix unnecessary import from zephyr.views.
Importing zephyr.views here has the unfortunate side effect of
creating Client ids 1 and 2 automatically (via decorators.py
instantiating the two client objects it makes), before we go ahead and
delete all objects in the database as part of the populate_db startup.

(imported from commit da03cb7606334d5926e42f422ab94d1c884937b9)
2012-12-14 17:15:32 -05:00
Tim Abbott dc2057ff73 dump_pointers and dump_passwords: Add error handling for deleted users.
(imported from commit 556c29133a4734014d4640d875c6d6fccc118668)
2012-12-14 17:15:32 -05:00
Tim Abbott ce40de14c9 Add a tool to save/restore user passwords.
(imported from commit 59bea04308bc0c42aeef840aa923dbef1919d31d)
2012-12-13 17:10:03 -05:00
Tim Abbott 434765d810 populate_db: Close database connections before shutting down.
This avoids some messages being logged by the postgres server.

(imported from commit 86aaa025a36dad6ec14d49b629cfb1ec326f929c)
2012-12-13 17:09:35 -05:00
Tim Abbott e330be7fc1 dump_pointers: Use timestamps, not IDs, for transmitting the pointer.
(imported from commit 9b51b9edc5b0bdfb2305c12a123d554811ec9e06)
2012-12-13 17:09:35 -05:00
Tim Abbott bda420a0f9 Fix email case issues when restoring user pointers.
(imported from commit 84d3288dffc1cb010d8cd2a749fe71aa2a4d0df3)
2012-12-13 17:09:34 -05:00
Tim Abbott 899cbabe23 populate_db: Make some more bits of memory possible for Python to free.
(imported from commit 2d8184d05f622475ffab1043a40251644a88c230)
2012-12-13 17:09:34 -05:00
Tim Abbott cfc3781841 populate_db: Fix StreamColor restore.
Previously, the StreamColor restore code didn't properly account for
the fact that most user subscriptions were in pending_subs and thus
not yet in the database.

(imported from commit 2e28c5a68aa045494b9336d7114c23f5c3706c28)
2012-12-13 17:09:34 -05:00
Tim Abbott 7707690231 Decrease memory usage in bulk_create for UserMessage objects.
By processing UserMessage objects in batches as we go, this avoids
consuming a large amount of memory that is linear in the size of the
messages log.

(imported from commit 0c42d97f0863da9c079836c60bebcbaeec59f849)
2012-12-13 17:09:34 -05:00
Luke Faraone 7ee945062d Add command to mark users as inactive.
This is useful when testing the sigup workflow, as this script enables you
to run through a MIT signup without manually creating a new inactive user
in the database.

(imported from commit c22649cc7c561c2fbe8682d1b17d7e5aba9ac04e)
2012-12-13 14:15:31 -05:00
Tim Abbott 1681651b7d Add dump_useractivity migration helper tool.
(imported from commit 6ceb437447c51be16b5eb0375de2f3bcf3fb14d0)
2012-12-12 15:45:55 -05:00
Tim Abbott a086307e6a Add command to dump and restore user pointers.
For use in database migrations.

(imported from commit f06ae569fe986da5e7d144c277bf27be534c04f9)
2012-12-12 15:45:35 -05:00
Tim Abbott 565acffbc5 Fix populate_db pointer restore.
(imported from commit e7984f5a762fde833c3b8520ef556fbd841aacbb)
2012-12-11 17:18:59 -05:00
Tim Abbott 3014a12cef populate_db: Truncate too-long messages on replay.
(imported from commit 4d89bf8a9235d5ed65863a851a13c91f4fb8632e)
2012-12-11 17:17:38 -05:00
Luke Faraone c65d6113ed Factor out notifying of a new user into a separate function, notify on manage.py create_user.
(imported from commit 1a6aa0536dbfea8035b6bbd76528e70d90aa8b60)
2012-12-07 17:32:16 -05:00
Luke Faraone 5b70b4a04f Introduce new manage.py command which creates users with default passwords.
(imported from commit ba5ed9cb6ee91435b184845019391e5dc38fc3aa)
2012-12-07 17:32:15 -05:00
Tim Abbott b5c8fd73f5 populate_db Use message_type variable consistently.
We previously were only using it at the first loop through all
messages, which meant code accessing the message type copied from one
place to another would break (potentially subtly), because things
would work if and only if the very last message happened to have the
same type as what is expected in the relevant piece of code.

(imported from commit ad9ce5efdb200e0c0d5c3ffa6db33113fdad8c5a)
2012-12-06 10:32:45 -05:00
Tim Abbott 28aa976be3 Fix desktop notifications being enabled on every settings change.
(imported from commit 09375c78125987de3223a17239fdef9273ccabe6)
2012-12-06 10:32:45 -05:00
Tim Abbott 8b15b11cbd populate_db: Simplify a bunch of message type checking code.
(imported from commit 6eaf857d3eef8d700c5251bdd242b9bbbc8cdb72)
2012-12-05 15:34:19 -05:00
Tim Abbott 970969fc44 Add new timestamp_to_datetime helper function.
(imported from commit 6791d009ae2e8371abe2c929e87c816a1981f5fe)
2012-12-05 15:34:19 -05:00
Tim Abbott f843152427 log_event: Clean up duplicated timestamp setting code.
(imported from commit dc3b3144ca23106bef2d953b00dc042115008703)
2012-12-05 15:34:19 -05:00
Tim Abbott 4d607c79f1 populate_db: Remove potentially confusing parenthesis.
(imported from commit 9d4dd543f0787c4eae5f7c697b7edcab4cdc8a7c)
2012-12-05 15:34:19 -05:00
Tim Abbott a6f744a11f populate_db: Fix inefficient pointer update at end of replay.
This cuts a 30s operation down to about 2s on my machine.

And also move the code to run before we print the "done" message and
have logging for how long it is taking.

(imported from commit 2f20f8ca3fee714735a50fe6c6cfd630df452768)
2012-12-05 15:34:18 -05:00
Tim Abbott 156f6ee576 Log an event on new realm creation.
(imported from commit 98872c7e5922fecd2bed9b544ff5fffd8147343c)
2012-12-05 15:34:18 -05:00
Tim Abbott 81d560dc1f populate_db: Preserve the user's date_joined on replay.
(imported from commit 91dcb4f41e0e58f165db6a7417e57548914ddab7)
2012-12-05 15:34:18 -05:00
Tim Abbott 8e3bcdaa19 Add user_created event type and appropriate replay code.
This is necessary for correctly replaying new user signups on non-MIT
domains.

(imported from commit e5a9d37b8772bd9794579ef16e7039196ac06f62)
2012-12-05 15:34:18 -05:00
Tim Abbott d6218a15b1 populate_db: Use a function to make email address fixups consistent.
Also add a missing fixup on the subscription events.

(imported from commit f7e2577fca8a3df3cef900c8535612ea8615b2e8)
2012-12-05 15:34:18 -05:00
Tim Abbott fc5e626515 populate_db: Update users table when processing newly created user.
(imported from commit cfcf620888e8d395ca2f808cfff1ee5de89ba2ac)
2012-12-05 15:34:18 -05:00
Tim Abbott a289efb425 populate_db: Request a new DB connection after run_parallel.
This is the only code change needed to make our code
postgres-compatible.

(imported from commit a94ad0856c46ead2892674fe18d86d49876a6160)
2012-12-04 10:59:26 -05:00
Tim Abbott eea553ce40 banish_broken: Fix handling of jesstess|MIT.EDU@mit.edu.
(imported from commit 50e596261dc678a1aa4b28bec34a6f592c8dc748)
2012-12-04 10:59:26 -05:00
Tim Abbott d850bc764f Fix stream name case issues in populate_db.
When we changed our stream name model to treat stream names as
case-insensitive, we didn't update populate_db to do the same.

This commit makes that update, which is to use the lower-cased stream
name for dictionary lookups and deduplication, but the original-case
stream name for actually creating streams.

(imported from commit fc32ec75a5ae286bce7ec86c6e6fb6893888cbd0)
2012-12-04 10:59:25 -05:00
Jessica McKellar 55e68fc89a Log subscription color changes so they can be replayed by populate_db.
(imported from commit 5c7f46ed0d727926e9819cb2d71eb31f241e2e34)
2012-12-03 12:46:27 -05:00
Keegan McAllister 3715583d29 Implement a command to expunge old UserMessages and Messages from the database
(imported from commit a4873dfa8737c483411d12f30daaebebebf859f9)
2012-11-30 17:24:37 -05:00
Keegan McAllister c8b6e72cbf Implement a command to expunge old entries from log files
(imported from commit 28bc40bf12dd8cea0ff9b842f72e7713640e55a6)
2012-11-30 17:24:37 -05:00
Tim Abbott bc2ace726c Fix bad Django test suite interaction with get_client default.
authenticated_api_view and authenticated_json_view call
update_user_activity with a client generated using
@has_request_variables with a default of e.g. get_client("website").
Because that get_client call only happens once on importing the
module, if those client objects didn't exist previously in the
fixtures, then the first test will generate objects with ids 2 and 3,
and then the second test will dump the database, restore from the
fixtures, and then eventually generate client objects with ids 4 and
5.  But since the default values were only computed at module load,
we'll still end calling add_user_activity with client objects with ids
2 and 3, which don't exist in the newly restored database.

Fix this madness by just making sure those two client objects exist in
the database.

(imported from commit d940e129d077a560d9a0f96ec3daa2e16ce21c8b)
2012-11-28 17:41:39 -05:00
Keegan McAllister b5dccbfa87 Return a special value to initiate longpolling
Fixes #261.

(imported from commit dd0312c3574c9ca924ab76edcb2fb6c03085be32)
2012-11-28 15:28:14 -05:00
Jessica McKellar 4832a6a1fe [schema] Add a management script to create default streams for a domain.
Run this script on an existing realm to create or change default
streams, which new users will get upon account creation.

(imported from commit 8938dcbd3520d97d25b4c6ca783d35c9aef52df0)
2012-11-28 14:07:16 -05:00
Jeff Arnold a6ec875268 [schema] Add enable_desktop_notifications to user profile
(imported from commit f5b543e8446263ce8855561441a6d4c1a8d41f4d)
2012-11-26 14:43:55 -05:00
Keegan McAllister ec6ebd034b Add Nagios bot user
(imported from commit e36ea06908b488e4003463e1afa34181fd299316)
2012-11-26 14:42:55 -05:00
Keegan McAllister b21bdc91cb Fix email addresses generated by populate_db --extra-users
(imported from commit bdb93e51966ca8c0e20d67cccbe50e80e2592127)
2012-11-23 19:19:46 -05:00
Luke Faraone dad00fa29f Add script to create new realms.
(imported from commit 764d41f28b1af10860ea4d03a6aa983f40d3ffd7)
2012-11-21 16:42:15 -05:00
Luke Faraone b1ba5bf1b2 [manual] Send a message when a new user creates an account.
(imported from commit 2c69be9bfbbe947db41188cbdfc05cf887dc858f)
2012-11-20 16:41:55 -05:00
Tim Abbott 4198dc74f1 Fix banish_broken tool.
(imported from commit 505c4a86ab106abab4c36af7c5f67c955f143c1d)
2012-11-14 16:57:21 -05:00
Tim Abbott b22249d861 Helper scripts to fix some buggy users.
We have a lot of forged users that have bad fullnames due to
historical versions of our fullname computations; this function will
clean those up.

Also, we have a bunch of users with emails like foo|mit.edu@mit.edu
that were the result of a mirroring bug that we want to get rid of
from autocomplete -- putting them in a useless realm name will do.

(imported from commit 6e305093653ca9d327e9e28491636e99d16cfe1d)
2012-11-14 15:03:49 -05:00
Keegan McAllister 31496e9189 Generalize Tornado-related settings
(imported from commit 76a1338a87e1a6663aa7602a499e2d769814bf08)
2012-11-13 10:59:02 -05:00
Tim Abbott de4548dcb5 populate_db: Don't give huddle senders 2 UserMessage rows per message.
This bug was caught by our new unique_together constraints.

(imported from commit 5392c12cdc8e5c9603652ba2a32ae4400375f14b)
2012-11-08 18:00:46 -05:00
Tim Abbott 2be66f0e8a populate_db: Don't create huddles with 2 copies of the same person in them.
Bug caught by our new unique_together constraints.

(imported from commit 37c1fc459b98050417e907653a5a4fc97004903b)
2012-11-08 17:59:31 -05:00
Keegan McAllister 246c0a37bc Get rid of bare 'raise' outside 'except'
Within 'except', 'raise' re-raises the current exception.  But outside, it produces

    TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

which is pretty confusing as a generic "something has gone wrong" exception.

(imported from commit 9fcd003a952b82df67726c26161dced079978a32)
2012-11-08 10:48:11 -05:00
Keegan McAllister 3b8dbbc7d7 Use django.utils.timezone.now consistently
(imported from commit f223d9c1f6c77012db342b8be7aaed964b9f18c6)
2012-11-07 18:51:33 -05:00
Tim Abbott ff369373bf populate_db: Strip whitespace from stream names.
(imported from commit a33b4983994040060f8d7631238250297f4d152e)
2012-11-07 17:30:50 -05:00
Tim Abbott 02b7bcf1a4 populate_db: Make double-unsubscribes not a fatal error.
(imported from commit 4dadb28f9c310659ddd780e98da70da55ace7187)
2012-11-07 15:49:45 -05:00
Tim Abbott 6a690d4d4a Create our various bot users without subscriptions.
(imported from commit 9f9249cdb295f147d8b8b5cef17709c9aaa66418)
2012-11-06 16:59:28 -05:00
Tim Abbott a6cd21a1b8 Log events to a file named after the current server.
Merging these log files together is future work.

(imported from commit 54abf1ed41c2d8ba220fd3af0d997256c2718db0)
2012-11-06 14:12:19 -05:00
Keegan McAllister e9c81a4a8b runtornado: Don't apply response middleware twice
This was causing us to log some requests twice, and might have more serious
consequences as well.

(imported from commit 0bb2d7207ee3e4e04679215a7f5ae637cd26aa19)
2012-11-06 13:15:49 -05:00
Keegan McAllister 8259059119 runtornado: Remove ability to run without specifying exactly one port
The zero-port case never actually worked, because addrport wasn't an optional
parameter in run_one.  And multiple ports was implemented using the
multiprocessing library, which is just bad news.  Since we have no need for
this, remove it before it can cause trouble.

(imported from commit 9d913924701f30d23ebe878b76c8f1f0da2800e2)
2012-11-06 13:15:49 -05:00
Luke Faraone 75c6fa7202 When doing a deployment, set the site name to app.humbughq.com.
(imported from commit b89f72f0cb94fae7678db570a1e9774dbe471ba9)
2012-10-30 15:13:12 -04:00
Luke Faraone 5dad59e864 Implement MIT signups.
Here we introduce a new manage.py command, activate_mit, which takes a
number of usernames and sends out emails to the users with instructions on
how to activate their accounts.

(imported from commit f14401b55f915698e83ff27b86434f53e64685f3)
2012-10-29 16:59:37 -04:00
Tim Abbott 6c39bf5cbd Cut out duplicated code between clear_database and populate_db.
(imported from commit 4bb44c20d2f0477d8a3db72788f82b0cf8572b2d)
2012-10-29 14:54:18 -04:00
Tim Abbott 9caf205ed9 Fix missing tables when clearing databases.
(imported from commit 950839216af8366b87564fb310cb1ac47711ae02)
2012-10-29 14:54:18 -04:00
Keegan McAllister da252e8499 runtornado: Abort view processing if request or view middleware returns a response
This is the behavior specified by Django.  Since this was broken before,
our CSRF protection had no effect on Tornado views other than printing
a warning message :(

(imported from commit 7975d3c9b6c18915f917ac2da4592a55f6b6a658)
2012-10-27 17:28:07 -04:00
Tim Abbott 7c8bde5d90 Add log/restore for fullnames and passwords.
(imported from commit 048ca3c86b9f077fcbccd5df4a509191a545da4c)
2012-10-25 15:52:26 -04:00
Keegan McAllister eef027560a Remove unused imports
(imported from commit eb576627ff72e57fee0e3a4c357f51ad74cd6c86)
2012-10-25 15:22:18 -04:00
Tim Abbott 8c4a834206 Add function for activating MIT users.
(imported from commit 0de45fc341249332909d5a0ecef4d49918658a1a)
2012-10-25 14:46:58 -04:00
Tim Abbott 722249a9fc Use a variable for repeatedly referencing old_message['type'].
(imported from commit 1b8e8fef61582dab06ffbb9a9b71c83c2629f0f2)
2012-10-25 14:46:43 -04:00
Tim Abbott 6e1ec1a2ec Move our various bots into api/bots/.
(imported from commit f5803441b9b84872b942dff8e1c0ad1100788bcd)
2012-10-25 13:53:34 -04:00
Tim Abbott f1e4a27106 Optimize populate_db's common code for setting up real users.
(imported from commit 074b30ac88101f8e00ddcb60b5b05defc0a11998)
2012-10-23 17:52:10 -04:00
Tim Abbott 1b67b6b711 Don't deliver messages to "fake" Zephyr users created by populate_db.
(imported from commit c88760a88382ffc07cf5f79f3093a2bfec429d53)
2012-10-23 17:52:10 -04:00
Tim Abbott a9667d81a8 Fix performance regression caused by last commit.
(imported from commit f0abf93dbab92c5627903284fafad310de039fe6)
2012-10-22 22:01:55 -04:00
Tim Abbott 8c16295301 populate_db: Fix replaying personal messages from logs.
(imported from commit 685a426fe59fa240c8ae5cf357a43d4df0a3f05d)
2012-10-22 21:36:32 -04:00
Tim Abbott 846469c39c [schema]: Rename userprofile to user_profile.
(imported from commit adfb6152b7ec32557e3465d961695eb870506d5a)
2012-10-22 18:55:45 -04:00
Zev Benjamin 732ca19729 Synchronize the pointer across sessions
The client may now optionally send its current pointer during
get_updates and the server will return the latest pointer if it
differs and was updated more recently by a different session.

(imported from commit e43b377d7dfb52f83cefb0b1003863d5407caf80)
2012-10-22 16:44:57 -04:00
Tim Abbott a695732bda Seed the populate_db random number generator.
This makes it not to produce 10 copies of each message.

(imported from commit 35ab5f14ec104b4ea52137dac4fa2840194f3777)
2012-10-22 13:59:46 -04:00
Tim Abbott d3a693080e Fix receiving messages on the ShakeSpeare streams.
(imported from commit 4ce60d57e66363da1bd3c2b93fcf008eee795769)
2012-10-20 19:54:29 -04:00
Tim Abbott dab25bdff7 populate_db: Be a little more defensive about message types.
(imported from commit fe23365180847065a9a3292f7873dcb36bb277db)
2012-10-20 19:48:05 -04:00
Tim Abbott 55d9c08c83 populate_db: Fix case bugs importing old messages.
(imported from commit dba8e3419f5827344a42f28c31798fdaff7cf002)
2012-10-20 19:43:06 -04:00
Tim Abbott dcfef6b1a9 Fix restored personals going to the wrong user.
(imported from commit 362c9f3d833c96a5f3530138a0e9360bff183cbf)
2012-10-20 19:20:48 -04:00
Tim Abbott 7b3b4362dd [schema] Add a Client model keeping track of the sending client.
(imported from commit 31a430b1de14ce973addafd5d13ace049a8f8091)
2012-10-20 18:41:54 -04:00
Tim Abbott 2c89103b23 Actually update current subscriptions based on changes in logs.
(imported from commit b36637562dd0e358f1718d38778c735bb75fd77a)
2012-10-20 18:41:51 -04:00
Tim Abbott 56dab6cb26 Log changes to subscriptions and replay them in populate_db.
(imported from commit d3055eb44326bdc59a6bc96d00b5b0bc6da86059)
2012-10-20 18:26:21 -04:00
Tim Abbott d68cf3696b populate_db replay: Use bulk_create to create objects.
This cuts the time required to import 38000 messages (with 140000
message receipts) from about 10 minutes to just under 40 seconds on my
laptop with sqlite.

(imported from commit d53b0d1360408c77f38353b58fbb25875262cb40)
2012-10-20 18:26:18 -04:00
Tim Abbott b2ce9aaa18 populate_db replay: Parse the json from old messages first.
(imported from commit bdd900b7618ce85d27eebe4d2a745c4d2734cb85)
2012-10-20 10:44:50 -04:00
Tim Abbott e434fa141e Use .objects.create and .objects.get_or_create.
This eliminates a bunch of unnecessary code and also fixes a bunch of
places where we were improperly not using transactions.

(imported from commit f194ae9226f9229fc56a0b1b21615534f486ea0c)
2012-10-19 17:42:14 -04:00
Keegan McAllister bbb67f61cc populate_db: Indicate progress on --replay-old-messages
(imported from commit 1f1043bca0952650c744d6012b11d607f2eb3cde)
2012-10-19 15:17:34 -04:00
Keegan McAllister b9e9938197 create_user_if_needed: Use proper initial passwords
(imported from commit 009208ac64548dd6f8773ccc7738ab0c391d816a)
2012-10-17 21:08:59 -04:00
Keegan McAllister ea916951f4 Disable notify_new_message calls in testing and populate_db
(imported from commit 07a0fea4173e2e27a90ac5f111927f0000377764)
2012-10-17 18:23:01 -04:00
Keegan McAllister a545876d56 Rename notify_waiting_clients -> notify_new_message
We might have other URLs for other notifications.

(imported from commit 4c1c5fe2f039816fef4c268f34692ca4f19d81e8)
2012-10-17 18:23:01 -04:00
Keegan McAllister b2103e61ef print_initial_password: Print API keys too
(imported from commit b4fccc2947cb2c2d9e5f732c6e151bc12f091683)
2012-10-17 18:23:01 -04:00
Keegan McAllister 8a1ba0d720 Add a management command to print the initial password for an account
(imported from commit 0a2b7d8215961801dbd24d9af89785e857b9ba14)
2012-10-17 18:23:01 -04:00
Keegan McAllister cc8a14fcf8 Create accounts with passwords which are deterministic but hard to guess (from the outside)
(imported from commit 964610fec6c4690c1e881f2bab252296663c819a)
2012-10-17 18:23:01 -04:00
Keegan McAllister 5e70b5a291 Split off the Tornado code into a separate process
(imported from commit 95dbd0f438cdba06d6e6c6c539a2a3d49c577cfd)
2012-10-17 18:23:01 -04:00
Tim Abbott 3e994c16b7 Rename/reorganize our urls to be more consistent.
(imported from commit ca3cc7ccd5d7da83a9c60968527378ee1118648e)
2012-10-16 15:56:06 -04:00
Tim Abbott 2de4d1d448 Add social and test to default subs added after DB dumps.
(imported from commit 828c733c9f5d1bdd5fc0aa2e162b800f8db7b22f)
2012-10-11 11:53:57 -04:00
Tim Abbott ac3f4393ff Rename instance to subject.
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
2012-10-10 18:01:39 -04:00
Tim Abbott 613010675c Rename class => stream in populate_db.py.
(imported from commit 8546b2e7823f8df0f69b317bb3c6df1a4da49537)
2012-10-10 17:48:17 -04:00
Tim Abbott 44e9e4cebf Rename Recipient.CLASS to Recipient.STREAM.
(imported from commit a530194163f7260c73921137fa1ff671f14516f6)
2012-10-10 17:47:13 -04:00
Tim Abbott 1fc4780a81 Rename create_class_if_needed to create_stream_if_needed.
(imported from commit 1bbc792332981723d3d29b24ad03811d62ced5f1)
2012-10-10 17:47:13 -04:00
Tim Abbott bc3646691d Rename create_classes to create_streams.
(imported from commit 5c2e1f840e4774d392554a4c4cf49746f10550a9)
2012-10-10 17:47:12 -04:00
Tim Abbott 95f95d7e54 klass => model as a local variable to refer to our models.
(imported from commit c58a3133bfd8db13d34f8def4cf73e7526214e8e)
2012-10-10 17:47:12 -04:00
Tim Abbott 8daff2e05e Rename ZephyrClass to Stream.
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00
Tim Abbott 2170c7a352 Rename zephyrs to messages in various local variables.
(imported from commit 91ac7e47c51fdcaf6559b06f07e36b041aad3e2c)
2012-10-10 10:29:48 -04:00
Keegan McAllister e1113a6d08 populate_db: Fix mit_subs_list import
(imported from commit b67abb47892d561b9e300a324528303694bcf8de)
2012-10-06 17:53:05 -04:00
Tim Abbott 9cfa8a868f populate_db: Read from the correct messages log path.
(imported from commit ec7ef103ddf06cdc89c02659ceefcab1f64c89e4)
2012-10-05 14:59:23 -04:00
Tim Abbott 52a36945fe populated_db: Rename many functions/variables from zephyr => message.
(imported from commit d796561eded00511e4dfd7fe2bd5ac102125d4ea)
2012-10-03 18:14:15 -04:00
Tim Abbott 1ab81cff92 [schema] Rename Zephyr => Message in the schema.
(imported from commit 4f402f150c45d2097d6b16943935e6e370b4f8d8)
2012-10-03 18:14:15 -04:00
Tim Abbott 83ceba0a2d Remove old /api/get_updates view.
(imported from commit 5a33a61bfb4b3aa40e28c356f5b4048db775b901)
2012-10-03 16:58:31 -04:00
Tim Abbott cca5f7b76a Rename do_send_zephyr to do_send_message.
(imported from commit df4dc741bf00a197ca5ab39373bc9a3eda379684)
2012-10-03 12:27:34 -04:00
Tim Abbott be1a890a09 populate_db: Restore users' pointers to last after database resets.
(imported from commit d6c5a58173602e7e07b6851a6d22ed129b4f3733)
2012-10-02 16:58:13 -04:00
Tim Abbott 5a5b5de650 Rename /api/v1/get_updates to /api/v1/get_messages.
(imported from commit f856637158cf9fda64ba333b532a5941de8fcbab)
2012-10-02 16:29:34 -04:00
Tim Abbott 18a3888373 [schema] Add an API for sending/receiving messages.
(imported from commit 209d525dc5892fc4c392a8ced1588c838cbb17c4)
2012-10-02 15:49:25 -04:00
Keegan McAllister 4e6a239580 populate_db: Default to mit.edu realm on inport
This is something of a temporary hack.  In the future, we should make
zephyr_mirror.py smarter about fixing up the realms.

(imported from commit bdcff1a834904616538f430b4513ec7619b95e95)
2012-09-28 18:35:38 -04:00
Tim Abbott b43dd303b6 Use tornado for new /api/get_updates query.
(imported from commit 84b85fc5bb0de4144fde00ea13d14f74b1dd9bd1)
2012-09-27 17:37:05 -04:00
Keegan McAllister 20240d869c Rename get_updates_longpoll to get_updates
(imported from commit 15635904584b324bdfa1414caea12c3bc4ce54c8)
2012-09-27 15:46:36 -04:00
Tim Abbott 699e05383f Log messages and restore them with populate_db.
(imported from commit 959f038a736e48d32819bc04bd054632a2e911c6)
2012-09-27 15:01:30 -04:00
Tim Abbott 2f4a96e18d Use better random generation of shakespeare lines.
(imported from commit f979a8476f6fd925b9041e15dd38a9c261341be9)
2012-09-27 15:01:30 -04:00
Tim Abbott c8220ee057 Don't store the post-markdown HTML in our database content column.
(imported from commit bb81e84acc04ea0930be1026149618fbb60174fd)
2012-09-26 14:51:14 -04:00
Tim Abbott 11e5e8785d Preparation for syncing messages back to MIT.
(imported from commit 551b697366702de93579de259a9bc644be8d66ec)
2012-09-24 14:31:40 -04:00
Tim Abbott a8e83040e5 Add support for specifying per-user MIT subscription lists.
(imported from commit d6e91917c071e59b5611bfefe326ac47684299c3)
2012-09-24 10:51:49 -04:00
Tim Abbott efd2cb8fa9 Add both Humbug and MIT internal users.
(imported from commit f300c6513a9756417285ba371cb2d3f6f26fc4a3)
2012-09-21 11:15:19 -04:00
Tim Abbott 2d6683f896 Deduplicate user creation code.
(imported from commit bda76a9a44bd5ed7f0726b527fdb93cec109cbed)
2012-09-21 10:45:00 -04:00
Tim Abbott 135c82717d Authenticate by email.
Approach from http://www.micahcarrick.com/django-email-authentication.html.

(imported from commit 796b8e08d8e1f9769cd3cf8ee61d3724ac3847b7)
2012-09-21 10:34:48 -04:00
Tim Abbott 967dc37bc2 Put the Shakespeare users in a different realm from the MIT ones.
(imported from commit c75bff78380ee85c00edb4690030b6e0c1b42360)
2012-09-20 18:03:43 -04:00
Keegan McAllister 209bfdf16a populate_db: style fixes
(imported from commit bf16e9a745407a95917e4765257c54dd342fcacc)
2012-09-20 11:22:39 -04:00
Keegan McAllister 16b53fc1ef populate_db: Provide option to create extra users
(imported from commit 13d24c2af3911a06138e73619aa6091a9aeb4f1a)
2012-09-20 10:47:25 -04:00
Keegan McAllister db7a8277ff Replace create_{user_profile,zephyr_class} with {UserProfile,ZephyrClass}.create
Looks nicer and cuts down on imports.

(imported from commit 4fdbbb45cf6d8ad016481c663cf52fd555b41d91)
2012-09-19 13:01:58 -04:00
Keegan McAllister c887a5f977 Debug Tornado when Django DEBUG = True
(imported from commit ebd81e5d9344f5fb09c59a2afcaf83e9b1fc2a1d)
2012-09-18 13:45:52 -04:00
Keegan McAllister f003dddebb populate_db: Remove unused variables
(imported from commit 3f8f40134858721b372f3971c3b7ced31f9ed49e)
2012-09-17 21:55:38 -04:00
Keegan McAllister bdb1c1b97e populate_db: Break up a long line
(imported from commit cb9d1a785751af6115cbbffc4f21bc09d38cc0fa)
2012-09-17 21:39:21 -04:00
Keegan McAllister 7152fe2f73 Format messages with Markdown
(imported from commit 014a4dddd4d3db61d85c6f6bf1987aff6093fb52)
2012-09-17 15:24:41 -04:00
Tim Abbott da2494004d Make populate_db thread count an option.
(imported from commit b65de0a25a7c345a422e8f4f236bf49025c97886)
2012-09-17 11:37:14 -04:00
Tim Abbott 0b699be7eb Add some caching of userprofile objects.
(imported from commit dd8e1bec2d677e873d90806aa71519c3a37221c8)
2012-09-17 11:37:11 -04:00
Tim Abbott 2fb626c106 Fix running populate_db more than once in a row.
(imported from commit 72a59b8e6a8cedeb5ca7d242fdfd40fb3f691bc3)
2012-09-14 16:25:11 -04:00
Tim Abbott 09b1285ac1 populate_db: Create the new zephyrs in parallel.
(imported from commit e550d4f6c68502ca27a3dbdc99a495a1c4e710ac)
2012-09-14 13:32:26 -04:00
Tim Abbott 4cc2a7ef60 Restructure populate_db to use more functions.
(imported from commit a2757292c6e2ea33433ebf2028c3322c00b03a2f)
2012-09-14 13:32:25 -04:00
Keegan McAllister 054c30a6db Move MIT Zephyr subs list into its own file
(imported from commit 260ed986c1d69c141e42bea4803ebe0396a86715)
2012-09-12 20:30:07 -04:00
Jessica McKellar e60959ab64 populate_db: give users full names.
(imported from commit db78a76d983dab077dfb105431e549b46e4c60d8)
2012-09-11 16:35:00 -04:00
Tim Abbott a983276b16 Add support for populate_db adding to the existing messages.
(imported from commit 765243923c67ff4820b4cd873764a5e8172cf177)
2012-09-11 10:50:48 -04:00
Tim Abbott 37b1c1db11 Stop using foo.pk when we mean foo.id.
(imported from commit b86359254415f65b32eeefdfbcb38d7bb862c1ac)
2012-09-10 13:43:17 -04:00