Commit Graph

16960 Commits

Author SHA1 Message Date
Rishi Gupta f9e56ad25d counts.py: Move DataCollector declarations into CountStat declarations.
The previous zerver_* names were unwieldy and not very readable. This also
puts more of the useful information in one place; in particular, makes it
easier to skim a CountStat declaration and see if we're collecting it at a
user/stream granularity or a realm granularity.
2017-04-14 11:41:07 -07:00
Rishi Gupta c20e79ab1f counts.py: Rename DataCollector.analytics_table to output_table. 2017-04-14 11:41:07 -07:00
Rishi Gupta 6369d23633 counts.py: Rename ZerverCountQuery to DataCollector.
Not the final form of DataCollector, but the name change causes a big diff
so separating it out.
2017-04-14 11:41:07 -07:00
Rishi Gupta b3991e2557 counts.py: Move CountStat.group_by into ZerverCountQuery.
Part of a larger refactoring to reduce cyclic dependencies between CountStat
and DataCollector (coming soon).
2017-04-14 11:41:07 -07:00
Rishi Gupta 341e1b54fc counts.py: Remove zerver_table from ZerverCountQuery.
Was only needed for filter_args, which are now gone.
2017-04-14 11:41:07 -07:00
Rishi Gupta 661de6bf25 counts.py: Remove filter_args argument from CountStat definition.
It turned out to not be that useful once we added subgroup. The previous
design of the CountStat object also assumed more reuseability of the *_query
strings than what ended up happening.

The filter_args also had some carrying costs:

* It's hard to be confident that filter_args other than the ones explicitly
  in our tests would have had expected behavior.
* The filter_args/join_args system is the most complex part of the CountStat
  object, and makes understanding the *_query strings unnecessarily
  difficult for a new contributor.
2017-04-14 11:41:07 -07:00
Rishi Gupta 4dfadba244 counts.py: Hardcode is_active=true in count_user_by_realm_query.
A step towards removing filter_args from the CountStat object.
2017-04-14 11:41:07 -07:00
Rishi Gupta 6bb97db136 analytics: Add active_users_audit:is_bot:day. 2017-04-14 11:41:07 -07:00
Rishi Gupta cc75d83b74 counts.py: Reorder count_stats_ to put similar stats together. 2017-04-14 11:41:07 -07:00
Rishi Gupta b396be4c98 models: Add index on RealmAuditLog.event_time.
Useful for the upcoming check_realmauditlog_by_user_query, if nothing else.

But I suspect it will indeed get use; looking for events around or within a
certain time is pretty natural for an audit log.

The main argument against I would say is that this should actually be a
joint index with something else. I'm not sure what that something else
should be, so just optimizing for what I think
check_realmauditlog_by_user_query will need for now.
2017-04-14 11:41:07 -07:00
Rishi Gupta 3d514c3e8d analytics: Add a default for the value column in assertTableState.
A default value of 1 is reasonable in this framework, especially for testing
things like LoggingCountStats.
2017-04-14 11:41:07 -07:00
Rishi Gupta ce376261ca models: Add comment explaining RealmAuditLog.backfilled. 2017-04-14 11:41:07 -07:00
Rishi Gupta 2f74ccabf9 analytics: Add 15day_actives CountStat. 2017-04-14 11:41:07 -07:00
Rishi Gupta 9b661ca91f analytics: Replace CountStat.is_gauge with interval.
Groundwork for allowing stats like "Monthly Active Users".

CountStat.interval is no longer as clean a value as before, so removed it
from views.get_chart_data. It wasn't being used by the frontend anyway.

Removing interval from logger calls in counts.py is not a big loss since we
now include the frequency (which is typically also the interval) in
CountStat.property.
2017-04-14 11:41:07 -07:00
Rishi Gupta d6c5c672d3 analytics: Add minutes_active CountStat. 2017-04-14 11:41:07 -07:00
Joshua Pan 6be482b0e7 Link /help/ documentation from in-app documentation.
Fixes: #4455.
2017-04-14 11:35:40 -07:00
Brock Whittaker fe8f63c389 message view: Fix rare cases where click-to-reply was not handled.
The comment explains this change is fairly good detail.  This change
is designed to fix complaints that sometimes clicking on a message to
reply doesn't work, which we can reproduce as being caused by clicks
that happen simultaneous with a few pixels of mouse motion at the same
time as the click.

Comment and commit message rewritten by tabbott for clarity.
2017-04-14 11:25:15 -07:00
hackerkid cd5334c827 Show local time of user in user_popover. 2017-04-14 10:38:29 -07:00
hackerkid 15cdd23525 Add option for setting timezone in user display settings. 2017-04-14 10:38:21 -07:00
hackerkid bf3b2ac673 Include timezone in user_dict fields.
Tweaked by tabbott to avoid adding timezone to bot dicts, since bots
don't need a timezone.
2017-04-14 10:33:55 -07:00
hackerkid 2a0a84b229 Add moment.js third-party module via npm.
This is needed for timezone manipulations.  We may be able to replace
XDate with it in the future as well.
2017-04-14 10:22:06 -07:00
derAnfaenger ecf9a50610 Clarify UI description of message retention. 2017-04-14 10:13:34 -07:00
Tim Abbott a417fd3c0b MessageDictTest: Fix nondeterministic query counts.
This fixes an issue with a nondeterministic number of database queries
being used in fetching bulk messages from the database.  The source of
the problem was that we were fetching _all_ messages, not just the 600
that had been created by the test, and thus if the set of streams
present in messages in the test fixtures (which is random) changes,
the number of streams used (and thus number of queries) would change.
2017-04-14 09:55:27 -07:00
Tim Abbott 622b7f00f7 test_runner: Fix unnecessary sleep(1) in database teardown.
Apparently, Django's _destroy_test_db has a mostly unnecessary
sleep(1) before dropping the database, which obviously wastes a bunch
of time in the single-test runtime of their database teardown logic.

We work around this by monkey-patching that function to not do the sleep.
2017-04-14 09:30:47 -07:00
Umair Khan a507a47778 testing: Use zulip_test_template for backend.
Instead of zulip_test, use zulip_test_template for backend DB. This
makes sure that the DB used by backend tests is different from the
DB, which will be zulip_test, used by Casper tests.
2017-04-14 10:23:31 +05:00
Umair Khan bf713bcdfe testing: Don't create DB twice for backend.
In backend tests, only call generate-fixtures when --generate-fixtures
is explicitly passed or is_template_database_current() returns False.

We don't need to flush cache for backend tests because we bounce the key
prefix used to create cache keys before running every test
2017-04-14 10:23:16 +05:00
Steve Howell e23b660ccc compose: Extract set_focus().
Most of the code here was in show_box(), but we also pull in the
call to get_focus_area() from compose.start().
2017-04-13 17:13:19 -07:00
Steve Howell 0841320966 compose: Extract maybe_scroll_up_selected_message().
The extraction here is straightforward, but where we put the
caller is a slightly subtle change.  Instead of continuing to
invoke this code at the end of show_box(), we instead call it
at the beginning of complete_starting_tasks().  This change is
valid, because show_box() and complete_starting_tasks() are only
ever called from compose.start().
2017-04-13 17:13:19 -07:00
Steve Howell aa5409cf3a compose: Extract complete_starting_tasks(). 2017-04-13 17:13:19 -07:00
Steve Howell e73b56c7b5 compose: Extract expand_compose_box(). 2017-04-13 17:13:19 -07:00
Steve Howell 79ff32a01e compose: Extract autosize_message_content(). 2017-04-13 17:13:19 -07:00
Umair Khan 519dcdb750 api_dev_fetch_api_key: Improve invalid email message.
Show a user friendly message to the user if email is invalid.
Currently we show a generic message:
"Your username or password is incorrect."
2017-04-13 12:48:13 -07:00
Umair Khan 80b019629c remote_user_sso: Improve invalid email message.
Show a user friendly message to the user if email is invalid.
Currently we show a generic message:
"Your username or password is incorrect."
2017-04-13 12:48:13 -07:00
Umair Khan 93aa478efb api_fetch_api_key: Improve invalid email message.
Show a user friendly message to the user if email is invalid.
Currently we show a generic message:
"Your username or password is incorrect."

The only backend which can accept a non-email username is LDAP.
So we check if it is enabled before showing the custom message.
2017-04-13 12:48:13 -07:00
Umair Khan ad2114a7a8 validator.py: Create a validator for login email.
This validator raises JsonableError exception.

Fixes: #2748
2017-04-13 12:48:13 -07:00
Rishi Gupta 6e425814bf analytics: Add a few tests for fixtures.py.
The code in fixtures.py is only called from populate_analytics_db, and is
only used for generating pretty fixture data for manual testing. This commit
adds tests for a few things that were easy to add tests for, and provides
some minimal coverage of the file, but is not meant to be comprehensive.
2017-04-13 12:37:47 -07:00
Rishi Gupta b555191ee7 analytics: Change subgroup and labels lists to dictionary in views.py.
A dict is more semantically appropriate than two lists with an assertion
that they be the same length.
2017-04-13 12:37:47 -07:00
Steve Howell f06bd41586 Fix PM list sort ordering during scrollback situations.
Before this fix, if you scrolled back in your PM history for a
person that you've had recent conversations with, then we would
backdate the record of their most recent conversation, and this
would make the sort ordering under the "Private messages"
section incorrect.

This commit fixes this error by re-writing the function
message_store.insert_recent_private_message() to check any
prior timestamps for that user.  It also optimizes the function
a bit to short-circuit in O(1) time for cases where a recipient
already has a more recent timestamp, by having a Dict keyed
on user_ids_string.
2017-04-13 12:13:20 -07:00
Steve Howell 24461762da Add test_insert_recent_private_message(). 2017-04-13 12:13:20 -07:00
Steve Howell f5550301cf Extract message_store.insert_recent_private_message().
This function is slightly easier to unit test, and it isolates us
from changing message formats.  This removes some extraneous
code that would ensure that message timestamps were >= 0 that
probaby dates back to some really old migrations.
2017-04-13 12:13:20 -07:00
Steve Howell 6b549248e8 Extract settings_filters.js. 2017-04-13 10:39:39 -07:00
Steve Howell 3e37f64f71 Extract settings_streams.js. 2017-04-13 10:39:39 -07:00
Steve Howell 70afb59cff Extract settings_users.js.
This affects three admin sections:

    * Users
    * Deactivated users
    * Bots
2017-04-13 10:39:39 -07:00
Steve Howell 0fc7b9907f Extract settings_org.js (and fix live updates).
This is mostly moving code, but we do add short-circuit logic
for some live-updating methods here.

Note that this affects two different sections of the admin app:

    * Organization settings
    * Authentication methods

We really want to move to one module per section, but there is some
legacy coupling that makes this difficult for now.
2017-04-13 10:39:39 -07:00
Steve Howell a3b44148af Extract settings_emoji.js. 2017-04-13 10:39:39 -07:00
Steve Howell 76ec9cf60b Fix bug with (un)subscribe button showing on wrong narrow.
We had a bug for a while where if somebody subscribed you to a
stream, and you were narrowed to another stream, we'd show
a button in the "trailing bookend" to "Unsubscribe" from the
current stream.  I'm not sure how long we had that bug, but it
was at least a couple months old, and I couldn't track down an
issue for it.

Now we make sure that the stream event for the subscription is
related to the current narrow.

Users should still see messages when they subscribe/unsubscribe
themselves or when another user re-subscribes them to the stream
that they are narrowed to.
2017-04-13 08:01:44 -07:00
Steve Howell 33eb5ad237 Add narrow.is_for_stream_id() helper. 2017-04-13 07:49:55 -07:00
Brock Whittaker ec956d6d6e integrations: Preserve scroll position on integration inspect.
This preserves the scrolltop state of the user when they enter into
an integration's specifics, so when they exit out it scrolls them
back down the page.

Fixes: #4424.
2017-04-12 21:14:21 -07:00
Tim Abbott 51233590a2 render_markdown_path: Remove unnecessary and broken caching.
The pages in question are already cached automatically by Zulip, and
the lru_cache decorator doesn't work, since `context` might contain
unhashable objects.
2017-04-12 20:29:04 -07:00
Tim Abbott 1747427bf3 upload: Fix URL for realm icons with S3 backend. 2017-04-12 19:48:24 -07:00