Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unread.js to typescript #6

Closed
wants to merge 160 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
9cc0ded
portico: Correct layout on deactivation pages.
karlstolley Dec 12, 2023
da74b9a
billing: Apply common styles to billing pages.
amanagr Dec 13, 2023
e9ce69a
populate_billing_realms: Call sessions with billing_user.
amanagr Dec 13, 2023
aebafcc
corporate: Show error page if mobile push data has not been uploaded.
laurynmm Dec 7, 2023
44e9171
register_server: POST requests take data, not params.
alexmv Dec 13, 2023
180dd00
portico: Update strings for RemoteRealm login flow.
karlstolley Dec 12, 2023
0d08fe9
remote_billing_email_confirm: Minor text changes.
amanagr Dec 13, 2023
19575b4
remote_activity: Hide deactivated remote servers.
alexmv Dec 13, 2023
c263635
remote_billing_login: Show different title for deactivate login.
amanagr Dec 13, 2023
63f4fc5
server_deactivate: Show error message for server on active plan.
amanagr Dec 13, 2023
f281199
billing_session: Push nocoverage comments down a layer.
timabbott Dec 13, 2023
7f26905
compose_actions: Hide compose box when navigating to inbox/recent view.
sayamsamal Dec 13, 2023
45a2f7e
portico: Pass requested sponsorship context to plan page.
amanagr Dec 12, 2023
af83093
billing: Remove some stale TODOs.
timabbott Dec 13, 2023
95f4b31
billing: Don't require data to add to legacy plan.
timabbott Dec 13, 2023
27d236f
popover: Fix user popover and profile for bot with inaccessible users.
sahil839 Dec 13, 2023
c61b353
gear_menu_popover: Update the rocket icon used for plan and pricing.
sayamsamal Dec 13, 2023
0c99420
stripe: Don't approve sponsorship for customers on paid plan.
amanagr Dec 13, 2023
998685f
sponsorship: Show sponsored plan name for sponsored orgs.
amanagr Dec 13, 2023
039f6af
billing: Link plan name to /plans page.
amanagr Dec 13, 2023
081d94c
stripe: Add user and org metadata to stripe payments.
amanagr Dec 13, 2023
9efb236
remote_billing_page: Fix redirects for self hosted login.
amanagr Dec 13, 2023
35b644c
populate_billing_realms: Don't create plan for sponsored remote realm.
amanagr Dec 13, 2023
e8500fb
support: Include sponsorship request for remote server support view.
laurynmm Dec 13, 2023
68d117e
support: Add sponsorship request information to remote support view.
laurynmm Dec 13, 2023
09c32cb
Revert "portico: Disable self-hosted tab for logged-in cloud users."
karlstolley Dec 13, 2023
c43eb10
mailmap: Add entry for Viktor Illmer.
timabbott Dec 13, 2023
f0d429d
remote_server: Handle data of non existent realms.
sahil839 Dec 13, 2023
1abe22b
mailmap: Add entry for Rohan Gudimetla.
timabbott Dec 13, 2023
484c0df
corporate: Move renewal_amount to BillingSession framework.
laurynmm Dec 12, 2023
a897d68
support: Add active plan information to remote server activity.
laurynmm Dec 12, 2023
8954589
support: Filter remote realm data query for customer realm None.
laurynmm Dec 13, 2023
6308e07
billing: Standardize remote server plan type IDs.
timabbott Dec 13, 2023
d040664
billing: Set the legacy plan type when migrating.
timabbott Dec 14, 2023
b8deb44
zilencer: Fix mismigrated plan type assertion.
timabbott Dec 14, 2023
bfa3d14
zilencer: Don't try to migrate ended plans.
timabbott Dec 14, 2023
1229e38
send_custom_email: Stop lying about the type of options.
alexmv Dec 13, 2023
62e6b10
send_email: Pull admins_only back into send_custom_email filtering.
alexmv Dec 13, 2023
791d66f
send_custom_email: Split out the sending to remote servers.
alexmv Dec 13, 2023
2de1a23
send_custom_email: Provide an unsubscribe link for remote servers.
alexmv Dec 13, 2023
2863b59
send_custom_email: Make --json an additional filter, not a target.
alexmv Dec 14, 2023
612f2c7
send_custom_email: Support JSON extra context with remote servers.
alexmv Dec 13, 2023
a5311c8
stripe: End legacy plan before approving full sponsorship.
amanagr Dec 14, 2023
10ef308
migrate_server_to_realm: Reset server tier during migration.
amanagr Dec 14, 2023
a13e42f
docs: Add missing spaces around code spans.
andersk Dec 14, 2023
651590c
remote_billing: Store acting users in remote user audit logs.
mateuszmandera Dec 14, 2023
8bce837
corporate: Add billing support email constant.
laurynmm Dec 14, 2023
92c1dfc
message_send: Optimize checking access to DM recipients.
sahil839 Dec 13, 2023
d893ff5
digest: Exclude bots with sender.is_bot, not sent_by_human.
andersk Dec 13, 2023
d7d5b6c
models: Move Message.sent_by_human to Client.default_read_by_sender.
andersk Dec 14, 2023
77a6f44
message_send: Add read_by_sender API parameter.
andersk Dec 14, 2023
c7245d5
models: Make ScheduledMessage.read_by_sender non-nullable.
andersk Dec 14, 2023
34a1be8
model: Use same name for legacy plan across the app.
amanagr Dec 14, 2023
d795400
billing: Allow upgrade scheduled legacy orgs to view billing page.
amanagr Dec 14, 2023
e02e0cd
models: Make it easier to debug current plan name and status.
amanagr Dec 14, 2023
036b115
zilencer: Avoid using stale last_audit_log_update.
timabbott Dec 14, 2023
863c1c2
zilencer: Log why the server got a 401.
alexmv Dec 14, 2023
4ef93de
zilencer: Set the remote server as the user in Sentry.
alexmv Dec 14, 2023
1757b88
billing: Offer release announcement subscriptions.
timabbott Dec 13, 2023
b8d05ae
portico: Update count of Tim's daughters on /team page.
alya Dec 14, 2023
83d6481
support: Add the remote realm's plan type to the support view.
laurynmm Dec 14, 2023
9067220
signup: Send status code 400 on invalid emails.
alexmv Dec 8, 2023
bedb68b
registration: Prevent injecting arbitrary strings via query param.
alexmv Dec 8, 2023
633ec69
realm: Enfore length restriction on jitsi_server_url at API level.
sahil839 Dec 14, 2023
94f0837
settings: Restrict length of realm Jitsi url custom input.
sahil839 Dec 14, 2023
8965f01
i18n: Update translation data from Transifex.
timabbott Dec 14, 2023
ba80084
remote_billing_page: Deny login for server / remote realm.
alya Dec 14, 2023
b4e92ec
zilencer: Don't consider deactivated realms to transfer server plan.
amanagr Dec 14, 2023
11dff6b
zilencer: Add tests for migrating customer from server to realm.
amanagr Dec 14, 2023
6e902de
node tests: Use noop helper function pattern in test files.
evykassirer Dec 14, 2023
b472d76
change_user_role: List role choices in --help output.
andersk Dec 14, 2023
53f4013
remote_server: Handle JsonableErrors and connection failures better.
timabbott Dec 14, 2023
d351353
zilencer: Fix server/register failing to check if server is deactivated.
mateuszmandera Dec 15, 2023
c12a9ee
stripe: Fix 'get_billable_licenses_for_customer' not using event_time.
prakhar1144 Dec 15, 2023
f5aa88e
billing: Don't show current license for legacy plan customers.
amanagr Dec 15, 2023
63e5712
push_notifications: Improve logging when not contacting bouncer.
timabbott Dec 14, 2023
0f2cc38
send_email: Support add_context for remote servers.
alexmv Dec 15, 2023
1f7b3d7
stream edit toggler: Update `select_tab` when changing hash."
evykassirer Dec 14, 2023
53b7e95
test_remote_billing: Extract remote server / realm login methods.
amanagr Dec 15, 2023
33e0436
test_stripe: Add 'billing_session" to StripeTest.
prakhar1144 Dec 14, 2023
1588f49
test_stripe: Add end-to-end test for RemoteRealm billing flow.
prakhar1144 Dec 13, 2023
4b5e897
sponsorship_approval: Fix punctuation.
amanagr Dec 15, 2023
0fe725f
test_stripe: Add tests to check sponsorship approval.
amanagr Dec 15, 2023
8102519
send_email: Remove `List-Unsubscribe-Post` from remote-server emails.
alexmv Dec 15, 2023
fb5137f
zilencer: Handle deleted realms nicely at server/analytics.
mateuszmandera Dec 15, 2023
ace8344
docs: Document manual update_analytics_counts.
timabbott Dec 15, 2023
2090a10
portico: Remove development environment testing plan.
alya Dec 7, 2023
3aed22d
gear_menu_popover: Enable `Plan management` in production.
amanagr Dec 12, 2023
97799b2
billing: Enable billing system in production.
timabbott Dec 13, 2023
9423cce
docs: Document plan management login tips.
timabbott Dec 14, 2023
1086245
billing: Refactor code to compute push status.
timabbott Dec 11, 2023
03323b0
push_notifications: Enforce max user count on self managed plan.
sahil839 Dec 12, 2023
48ee750
zilencer: Log the can_push value that we returned.
alexmv Dec 14, 2023
8fb1265
sponsorship: Show different discount text for self hosted orgs.
amanagr Dec 7, 2023
b377673
sponsorship: Add help link redirect for org_type dropdown.
amanagr Dec 7, 2023
356d775
billing: Clarify minimum purchase license numbers.
karlstolley Dec 15, 2023
5d7010c
billing: Update copy, modal for self-hosted downgrades and trials.
karlstolley Dec 11, 2023
6d48e08
portico: Update modal for canceling scheduled legacy upgrade.
karlstolley Dec 11, 2023
f65478f
help: New page to document self-hosted billing.
alya Dec 1, 2023
d25c375
billing: Show self-hosted help link for licenses.
karlstolley Dec 12, 2023
eb2882d
help: Adjust Zulip Cloud vs. self-hosting help page.
alya Dec 13, 2023
fc9cfc0
help: Update Contact support documentation for new paid plans.
alya Dec 11, 2023
92de3d1
portico: Add self-hosted plans comparison table.
karlstolley Dec 5, 2023
e44ba3b
portico: Add new self-hosted plans.
karlstolley Dec 5, 2023
910a816
billing: Don't ask about subscriptions when deactivating registration.
alya Dec 15, 2023
bbd7912
i18n: Update translation data from Transifex.
timabbott Dec 15, 2023
bc13f0e
Release Zulip Server 8.0.
timabbott Dec 15, 2023
7b80af6
Update version following 8.0 release.
timabbott Dec 15, 2023
f1597af
send_email: Send emails to remote servers from BILLING_SUPPORT_EMAIL.
alexmv Dec 15, 2023
a37b36c
changelog: Fix version number typo.
andersk Dec 15, 2023
d50e9b5
version: Update to point to 8.0 blog post.
alexmv Dec 15, 2023
940c2a1
remote_billing_page: Allow deactivation logins with realm plans.
alexmv Dec 15, 2023
839b04a
docs: Update example run-dev output.
andersk Dec 15, 2023
9d11f2c
echo: Update build_display_recipient comment.
andersk Dec 15, 2023
e601d0a
models: Rename zerver/models.py to zerver/models/__init__.py.
andersk Dec 5, 2023
37a9c45
models: Extract zerver.models.constants.
andersk Dec 5, 2023
45bb8d2
models: Extract zerver.models.users.
andersk Dec 15, 2023
7001a0d
models: Extract zerver.models.groups.
andersk Dec 15, 2023
cd96193
models: Extract zerver.models.realms.
andersk Dec 15, 2023
67fb485
models: Extract zerver.models.realm_emoji.
andersk Dec 15, 2023
21ab385
models: Extract zerver.models.linkifiers.
andersk Dec 15, 2023
33610c8
models: Extract zerver.models.realm_playgrounds.
andersk Dec 15, 2023
3c11fd9
models: Move some functions to zerver.lib.display_recipient.
andersk Dec 15, 2023
51f1dc2
models: Extract zerver.models.recipients.
andersk Dec 15, 2023
927d7a9
models: Extract zerver.models.prereg_users.
andersk Dec 15, 2023
5391ec9
models: Extract zerver.models.push_notifications.
andersk Dec 15, 2023
4aa2d76
models: Extract zerver.models.streams.
andersk Dec 15, 2023
ea2ee61
models: Extract zerver.models.user_topics.
andersk Dec 15, 2023
2394b37
models: Extract zerver.models.muted_users.
andersk Dec 15, 2023
bac0279
models: Extract zerver.models.clients.
andersk Dec 15, 2023
b15999c
models: Extract zerver.models.messages.
andersk Dec 15, 2023
09d0abf
models: Extract zerver.models.drafts.
andersk Dec 15, 2023
cff0b78
models: Move some functions to zerver.lib.attachments.
andersk Dec 15, 2023
9fb5773
models: Extract zerver.models.user_activity.
andersk Dec 15, 2023
73e6805
models: Extract zerver.models.presence.
andersk Dec 15, 2023
c9c819e
models: Extract zerver.models.scheduled_jobs.
andersk Dec 15, 2023
68d3b9f
models: Extract zerver.models.realm_audit_logs.
andersk Dec 15, 2023
d5410b5
models: Extract zerver.models.onboarding_steps.
andersk Dec 15, 2023
27c0b50
models: Extract zerver.models.custom_profile_fields.
andersk Dec 15, 2023
1f1b2f9
models: Extract zerver.models.bots.
andersk Dec 15, 2023
33d140c
models: Extract zerver.models.alert_words.
andersk Dec 15, 2023
c343d7c
models: Move query_for_ids to zerver.lib.query_helpers.
andersk Dec 15, 2023
b38f3d2
models: Extract zerver.models.lookups.
andersk Dec 15, 2023
d85462a
pricing_plans: Fix scrollbars always visible.
amanagr Dec 16, 2023
6b1f718
plans: Fix same page hashtag link.
amanagr Dec 16, 2023
1e0339c
plans: Fix community plan documentation.
timabbott Dec 17, 2023
311a645
sponsorship_request: Minor changes.
amanagr Dec 17, 2023
5dc1d36
zilencer: Fix community plan push notifications.
timabbott Dec 17, 2023
24dc2e7
message_store: Migrate message_store to typescript.
evykassirer Dec 9, 2023
3993697
zilencer: Fix can_push logging bug with system bot realms.
timabbott Dec 17, 2023
5c9bb51
unread: Use some clearer variable names.
evykassirer Dec 13, 2023
722494b
unread: Rename KeyDict to key_to_bucket.
evykassirer Dec 13, 2023
6596598
unread: Create key_to_bucket object in call to constructor.
evykassirer Dec 13, 2023
f15a687
unread: Use message type instead of checking stream_id.
evykassirer Dec 13, 2023
bfff48d
unread: Return objects directly, no functional change.
evykassirer Dec 13, 2023
02257b8
ts: Migrate `popover_menus` to typescript.
Lalit3716 Nov 18, 2023
fbce7ea
FoldDict: Always use IterableIterator.
evykassirer Dec 21, 2023
05183f7
unread: Remove Bucketer in favor of simpler Map.
evykassirer Dec 21, 2023
67c18e1
unread: Return consistent data structure in unread_count_info_for_str…
evykassirer Dec 21, 2023
c5a1d07
unread: Convert module to TypeScript.
evykassirer Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Rishi Gupta <rishig@zulipchat.com> <rishig@users.noreply.github.com>
Rixant Rokaha <rixantrokaha@gmail.com>
Rixant Rokaha <rixantrokaha@gmail.com> <rishantrokaha@gmail.com>
Rixant Rokaha <rixantrokaha@gmail.com> <rrokaha@caldwell.edu>
Rohan Gudimetla <rohan.gudimetla07@gmail.com>
Sahil Batra <sahil@zulip.com> <35494118+sahil839@users.noreply.github.com>
Sahil Batra <sahil@zulip.com> <sahilbatra839@gmail.com>
Satyam Bansal <sbansal1999@gmail.com>
Expand All @@ -120,6 +121,7 @@ Tim Abbott <tabbott@zulip.com> <tabbott@zulipchat.com>
Ujjawal Modi <umodi2003@gmail.com> <99073049+Ujjawal3@users.noreply.github.com>
umkay <ukhan@zulipchat.com> <umaimah.k@gmail.com>
umkay <ukhan@zulipchat.com> <umkay@users.noreply.github.com>
Viktor Illmer <1476338+v-ji@users.noreply.github.com>
Vishnu KS <vishnu@zulip.com> <hackerkid@vishnuks.com>
Vishnu KS <vishnu@zulip.com> <yo@vishnuks.com>
Waseem Daher <wdaher@zulip.com> <wdaher@dropbox.com>
Expand Down
2 changes: 1 addition & 1 deletion analytics/management/commands/populate_analytics_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
Recipient,
Stream,
Subscription,
SystemGroups,
UserGroup,
UserProfile,
)
from zerver.models.groups import SystemGroups


class Command(BaseCommand):
Expand Down
35 changes: 33 additions & 2 deletions analytics/tests/test_activity_views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import uuid
from datetime import timedelta
from unittest import mock

from django.utils.timezone import now as timezone_now

from corporate.lib.stripe import add_months
from corporate.models import Customer, CustomerPlan, LicenseLedger
from zerver.lib.test_classes import ZulipTestCase
from zerver.models import Client, UserActivity, UserProfile
from zilencer.models import RemoteRealmAuditLog, get_remote_server_guest_and_non_guest_count
from zilencer.models import (
RemoteRealmAuditLog,
RemoteZulipServer,
get_remote_server_guest_and_non_guest_count,
)

event_time = timezone_now() - timedelta(days=3)
data_list = [
Expand Down Expand Up @@ -99,8 +106,32 @@ def test_activity(self, unused_mock: mock.Mock) -> None:
result = self.client_get("/activity")
self.assertEqual(result.status_code, 200)

# Add data for remote activity page
RemoteRealmAuditLog.objects.bulk_create([RemoteRealmAuditLog(**data) for data in data_list])
with self.assert_database_query_count(6):
remote_server = RemoteZulipServer.objects.get(id=1)
customer = Customer.objects.create(remote_server=remote_server)
plan = CustomerPlan.objects.create(
customer=customer,
billing_cycle_anchor=timezone_now(),
billing_schedule=CustomerPlan.BILLING_SCHEDULE_ANNUAL,
tier=CustomerPlan.TIER_SELF_HOSTED_BUSINESS,
price_per_license=8000,
next_invoice_date=add_months(timezone_now(), 12),
)
LicenseLedger.objects.create(
licenses=10,
licenses_at_next_renewal=10,
event_time=timezone_now(),
is_renewal=True,
plan=plan,
)
RemoteZulipServer.objects.create(
uuid=str(uuid.uuid4()),
api_key="magic_secret_api_key",
hostname="demo.example.com",
contact_email="email@example.com",
)
with self.assert_database_query_count(10):
result = self.client_get("/activity/remote")
self.assertEqual(result.status_code, 200)

Expand Down
24 changes: 13 additions & 11 deletions analytics/tests/test_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,19 @@
Client,
Huddle,
Message,
NotificationTriggers,
PreregistrationUser,
Realm,
RealmAuditLog,
Recipient,
Stream,
SystemGroups,
UserActivityInterval,
UserGroup,
UserProfile,
get_client,
get_user,
is_cross_realm_bot_email,
)
from zerver.models.clients import get_client
from zerver.models.groups import SystemGroups
from zerver.models.scheduled_jobs import NotificationTriggers
from zerver.models.users import get_user, is_cross_realm_bot_email
from zilencer.models import (
RemoteInstallationCount,
RemotePushDeviceToken,
Expand Down Expand Up @@ -1459,8 +1458,9 @@ def test_mobile_pushes_received_count(self) -> None:
now = timezone_now()
with time_machine.travel(now, tick=False), mock.patch(
"zilencer.views.send_android_push_notification", return_value=1
), mock.patch(
"zilencer.views.send_apple_push_notification", return_value=1
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
return_value=10,
), self.assertLogs(
"zilencer.views", level="INFO"
):
Expand Down Expand Up @@ -1519,8 +1519,9 @@ def test_mobile_pushes_received_count(self) -> None:
}
with time_machine.travel(now, tick=False), mock.patch(
"zilencer.views.send_android_push_notification", return_value=1
), mock.patch(
"zilencer.views.send_apple_push_notification", return_value=1
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
return_value=10,
), self.assertLogs(
"zilencer.views", level="INFO"
):
Expand Down Expand Up @@ -1578,8 +1579,9 @@ def test_mobile_pushes_received_count(self) -> None:

with time_machine.travel(now, tick=False), mock.patch(
"zilencer.views.send_android_push_notification", return_value=1
), mock.patch(
"zilencer.views.send_apple_push_notification", return_value=1
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
return_value=10,
), self.assertLogs(
"zilencer.views", level="INFO"
):
Expand Down
3 changes: 2 additions & 1 deletion analytics/tests/test_stats_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from analytics.views.stats import rewrite_client_arrays, sort_by_totals, sort_client_labels
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_day, ceiling_to_hour, datetime_to_timestamp
from zerver.models import Client, get_realm
from zerver.models import Client
from zerver.models.realms import get_realm


class TestStatsEndpoint(ZulipTestCase):
Expand Down
90 changes: 81 additions & 9 deletions analytics/tests/test_support_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Customer,
CustomerPlan,
LicenseLedger,
SponsoredPlanTypes,
ZulipSponsorshipRequest,
get_current_plan_by_realm,
get_customer_by_realm,
)
Expand All @@ -21,15 +23,8 @@
from zerver.actions.user_settings import do_change_user_setting
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import reset_email_visibility_to_everyone_in_zulip_realm
from zerver.models import (
MultiuseInvite,
PreregistrationUser,
Realm,
UserMessage,
UserProfile,
get_org_type_display_name,
get_realm,
)
from zerver.models import MultiuseInvite, PreregistrationUser, Realm, UserMessage, UserProfile
from zerver.models.realms import OrgTypeEnum, get_org_type_display_name, get_realm
from zilencer.lib.remote_counts import MissingDataError

if TYPE_CHECKING:
Expand All @@ -43,6 +38,24 @@
class TestRemoteServerSupportEndpoint(ZulipTestCase):
@override
def setUp(self) -> None:
def add_sponsorship_request(
hostname: str, org_type: int, website: str, paid_users: str, plan: str
) -> None:
remote_server = RemoteZulipServer.objects.get(hostname=hostname)
customer = Customer.objects.create(
remote_server=remote_server, sponsorship_pending=True
)
ZulipSponsorshipRequest.objects.create(
customer=customer,
org_type=org_type,
org_website=website,
org_description="We help people.",
expected_total_users="20-35",
paid_users_count=paid_users,
paid_users_description="",
requested_plan=plan,
)

super().setUp()

# Set up some initial example data.
Expand All @@ -52,6 +65,23 @@ def setUp(self) -> None:
hostname=hostname, contact_email=f"admin@{hostname}", plan_type=1, uuid=uuid.uuid4()
)

# Add example sponsorship request data
add_sponsorship_request(
hostname="zulip-1.example.com",
org_type=OrgTypeEnum.Community.value,
website="",
paid_users="None",
plan=SponsoredPlanTypes.BUSINESS.value,
)

add_sponsorship_request(
hostname="zulip-2.example.com",
org_type=OrgTypeEnum.OpenSource.value,
website="example.org",
paid_users="",
plan=SponsoredPlanTypes.COMMUNITY.value,
)

def test_search(self) -> None:
self.login("cordelia")

Expand All @@ -77,6 +107,19 @@ def test_search(self) -> None:
self.assert_in_success_response(["<b>Max monthly messages</b>: 1000"], result)
self.assert_not_in_success_response(["<h3>zulip-2.example.com</h3>"], result)

# Sponsorship request information
self.assert_in_success_response(["<li><b>Organization type</b>: Community</li>"], result)
self.assert_in_success_response(
["<li><b>Organization website</b>: No website submitted</li>"], result
)
self.assert_in_success_response(["<li><b>Paid users</b>: None</li>"], result)
self.assert_in_success_response(["<li><b>Requested plan</b>: Business</li>"], result)
self.assert_in_success_response(
["<li><b>Organization description</b>: We help people.</li>"], result
)
self.assert_in_success_response(["<li><b>Estimated total users</b>: 20-35</li>"], result)
self.assert_in_success_response(["<li><b>Description of paid users</b>: </li>"], result)

with mock.patch(
"analytics.views.support.compute_max_monthly_messages", side_effect=MissingDataError
):
Expand All @@ -96,6 +139,35 @@ def test_search(self) -> None:
self.assert_in_success_response(["<b>Contact email</b>: admin@zulip-2.example.com"], result)
self.assert_not_in_success_response(["<h3>zulip-1.example.com</h3>"], result)

# Sponsorship request information
self.assert_in_success_response(
["<li><b>Organization type</b>: Open-source project</li>"], result
)
self.assert_in_success_response(
["<li><b>Organization website</b>: example.org</li>"], result
)
self.assert_in_success_response(["<li><b>Paid users</b>: </li>"], result)
self.assert_in_success_response(["<li><b>Requested plan</b>: Community</li>"], result)
self.assert_in_success_response(
["<li><b>Organization description</b>: We help people.</li>"], result
)
self.assert_in_success_response(["<li><b>Estimated total users</b>: 20-35</li>"], result)
self.assert_in_success_response(["<li><b>Description of paid users</b>: </li>"], result)

result = self.client_get("/activity/remote/support", {"q": "admin@zulip-3.example.com"})
self.assert_in_success_response(["<h3>zulip-3.example.com</h3>"], result)
self.assert_in_success_response(["<b>Contact email</b>: admin@zulip-3.example.com"], result)
self.assert_not_in_success_response(["<h3>zulip-1.example.com</h3>"], result)

# Sponsorship request information
self.assert_not_in_success_response(
["<li><b>Organization description</b>: We help people.</li>"], result
)
self.assert_not_in_success_response(
["<li><b>Estimated total users</b>: 20-35</li>"], result
)
self.assert_not_in_success_response(["<li><b>Description of paid users</b>: </li>"], result)


class TestSupportEndpoint(ZulipTestCase):
def test_search(self) -> None:
Expand Down
3 changes: 2 additions & 1 deletion analytics/views/installation_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from analytics.views.support import get_plan_type_string
from zerver.decorator import require_server_admin
from zerver.lib.request import has_request_variables
from zerver.models import Realm, get_org_type_display_name
from zerver.models import Realm
from zerver.models.realms import get_org_type_display_name

if settings.BILLING_ENABLED:
from corporate.lib.analytics import (
Expand Down
25 changes: 22 additions & 3 deletions analytics/views/remote_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
remote_installation_stats_link,
remote_installation_support_link,
)
from corporate.lib.analytics import get_plan_data_by_remote_server
from zerver.decorator import require_server_admin
from zilencer.models import get_remote_server_guest_and_non_guest_count

Expand Down Expand Up @@ -69,6 +70,7 @@ def get_remote_server_activity(request: HttpRequest) -> HttpResponse:
left join icount on icount.server_id = rserver.id
left join mobile_push_forwarded_count on mobile_push_forwarded_count.server_id = rserver.id
left join remote_push_devices on remote_push_devices.server_id = rserver.id
where not deactivated
order by latest_value DESC NULLS LAST, push_user_count DESC NULLS LAST
"""
)
Expand All @@ -82,6 +84,9 @@ def get_remote_server_activity(request: HttpRequest) -> HttpResponse:
"Mobile users",
"Last update time",
"Mobile pushes forwarded",
"Plan name",
"Plan status",
"ARR",
"Non guest users",
"Guest users",
"Links",
Expand All @@ -90,13 +95,27 @@ def get_remote_server_activity(request: HttpRequest) -> HttpResponse:
rows = get_query_data(query)
total_row = []
totals_columns = [4, 5]
plan_data_by_remote_server = get_plan_data_by_remote_server()

for row in rows:
stats = remote_installation_stats_link(row[0])
support = remote_installation_support_link(row[1])
links = stats + " " + support
# Add estimated revenue for server
server_plan_data = plan_data_by_remote_server.get(row[0])
if server_plan_data is None:
row.append("---")
row.append("---")
row.append("---")
else:
row.append(server_plan_data.current_plan_name)
row.append(server_plan_data.current_status)
row.append(server_plan_data.annual_revenue)
# Add user counts
remote_server_counts = get_remote_server_guest_and_non_guest_count(row[0])
row.append(remote_server_counts.non_guest_user_count)
row.append(remote_server_counts.guest_user_count)
# Add links
stats = remote_installation_stats_link(row[0])
support = remote_installation_support_link(row[1])
links = stats + " " + support
row.append(links)
for i, col in enumerate(cols):
if col == "Last update time":
Expand Down
3 changes: 2 additions & 1 deletion analytics/views/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from zerver.lib.streams import access_stream_by_id
from zerver.lib.timestamp import convert_to_UTC
from zerver.lib.validator import to_non_negative_int
from zerver.models import Client, Realm, Stream, UserProfile, get_realm
from zerver.models import Client, Realm, Stream, UserProfile
from zerver.models.realms import get_realm

if settings.ZILENCER_ENABLED:
from zilencer.models import RemoteInstallationCount, RemoteRealmCount, RemoteZulipServer
Expand Down
Loading