2022-09-30 15:24:39 +02:00
|
|
|
import os
|
2019-09-19 23:14:25 +02:00
|
|
|
from datetime import timedelta
|
2021-07-25 15:28:47 +02:00
|
|
|
from typing import Any, Dict, List, Mapping, Type, Union
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2022-09-30 15:24:39 +02:00
|
|
|
from django.core.files.uploadedfile import UploadedFile
|
2017-04-15 04:03:56 +02:00
|
|
|
from django.utils.timezone import now as timezone_now
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import TypeAlias, override
|
2017-01-07 04:21:34 +01:00
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
from analytics.lib.counts import COUNT_STATS, CountStat, do_drop_all_analytics_tables
|
2017-01-16 20:25:06 +01:00
|
|
|
from analytics.lib.fixtures import generate_time_series_data
|
|
|
|
from analytics.lib.time_utils import time_range
|
2020-06-11 00:54:34 +02:00
|
|
|
from analytics.models import (
|
|
|
|
BaseCount,
|
|
|
|
FillState,
|
|
|
|
InstallationCount,
|
|
|
|
RealmCount,
|
|
|
|
StreamCount,
|
|
|
|
UserCount,
|
|
|
|
)
|
2022-04-14 23:58:15 +02:00
|
|
|
from zerver.actions.create_realm import do_create_realm
|
2022-04-14 23:48:28 +02:00
|
|
|
from zerver.actions.users import do_change_user_role
|
2019-09-19 23:14:25 +02:00
|
|
|
from zerver.lib.create_user import create_user
|
2024-05-24 16:49:56 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2022-09-30 15:24:39 +02:00
|
|
|
from zerver.lib.storage import static_path
|
2022-03-12 13:46:20 +01:00
|
|
|
from zerver.lib.stream_color import STREAM_ASSIGNMENT_COLORS
|
2017-01-07 04:21:34 +01:00
|
|
|
from zerver.lib.timestamp import floor_to_day
|
2023-02-28 04:02:25 +01:00
|
|
|
from zerver.lib.upload import upload_message_attachment_from_request
|
2023-04-19 21:31:09 +02:00
|
|
|
from zerver.models import (
|
|
|
|
Client,
|
2024-04-02 18:39:18 +02:00
|
|
|
NamedUserGroup,
|
2023-04-19 21:31:09 +02:00
|
|
|
Realm,
|
|
|
|
RealmAuditLog,
|
|
|
|
Recipient,
|
|
|
|
Stream,
|
|
|
|
Subscription,
|
|
|
|
UserProfile,
|
|
|
|
)
|
2023-12-15 01:55:59 +01:00
|
|
|
from zerver.models.groups import SystemGroups
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-01-07 04:21:34 +01:00
|
|
|
|
2024-05-24 16:49:56 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2017-01-07 04:21:34 +01:00
|
|
|
help = """Populates analytics tables with randomly generated data."""
|
|
|
|
|
2017-01-16 20:25:06 +01:00
|
|
|
DAYS_OF_DATA = 100
|
2017-01-17 22:55:16 +01:00
|
|
|
random_seed = 26
|
2017-01-16 20:25:06 +01:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
def generate_fixture_data(
|
|
|
|
self,
|
|
|
|
stat: CountStat,
|
|
|
|
business_hours_base: float,
|
|
|
|
non_business_hours_base: float,
|
|
|
|
growth: float,
|
|
|
|
autocorrelation: float,
|
|
|
|
spikiness: float,
|
|
|
|
holiday_rate: float = 0,
|
|
|
|
partial_sum: bool = False,
|
|
|
|
) -> List[int]:
|
2017-01-17 22:55:16 +01:00
|
|
|
self.random_seed += 1
|
2017-01-16 20:25:06 +01:00
|
|
|
return generate_time_series_data(
|
2021-02-12 08:19:30 +01:00
|
|
|
days=self.DAYS_OF_DATA,
|
|
|
|
business_hours_base=business_hours_base,
|
|
|
|
non_business_hours_base=non_business_hours_base,
|
|
|
|
growth=growth,
|
|
|
|
autocorrelation=autocorrelation,
|
|
|
|
spikiness=spikiness,
|
|
|
|
holiday_rate=holiday_rate,
|
|
|
|
frequency=stat.frequency,
|
|
|
|
partial_sum=partial_sum,
|
|
|
|
random_seed=self.random_seed,
|
|
|
|
)
|
2017-01-16 20:25:06 +01:00
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2017-11-05 06:54:00 +01:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2018-07-09 11:43:59 +02:00
|
|
|
# TODO: This should arguably only delete the objects
|
|
|
|
# associated with the "analytics" realm.
|
2017-01-16 20:13:18 +01:00
|
|
|
do_drop_all_analytics_tables()
|
2018-07-09 11:43:59 +02:00
|
|
|
|
|
|
|
# This also deletes any objects with this realm as a foreign key
|
2021-02-12 08:20:45 +01:00
|
|
|
Realm.objects.filter(string_id="analytics").delete()
|
2017-01-07 04:21:34 +01:00
|
|
|
|
2018-07-09 11:43:59 +02:00
|
|
|
# Because we just deleted a bunch of objects in the database
|
|
|
|
# directly (rather than deleting individual objects in Django,
|
|
|
|
# in which case our post_save hooks would have flushed the
|
|
|
|
# individual objects from memcached for us), we need to flush
|
|
|
|
# memcached in order to ensure deleted objects aren't still
|
|
|
|
# present in the memcached cache.
|
|
|
|
from zerver.apps import flush_cache
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2018-07-09 11:43:59 +02:00
|
|
|
flush_cache(None)
|
|
|
|
|
2017-04-15 04:03:56 +02:00
|
|
|
installation_time = timezone_now() - timedelta(days=self.DAYS_OF_DATA)
|
|
|
|
last_end_time = floor_to_day(timezone_now())
|
2021-03-08 13:22:43 +01:00
|
|
|
realm = do_create_realm(
|
2021-02-12 08:20:45 +01:00
|
|
|
string_id="analytics", name="Analytics", date_created=installation_time
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-03-08 13:22:43 +01:00
|
|
|
|
2022-09-13 22:14:07 +02:00
|
|
|
shylock = create_user(
|
|
|
|
"shylock@analytics.ds",
|
|
|
|
"Shylock",
|
|
|
|
realm,
|
|
|
|
full_name="Shylock",
|
|
|
|
role=UserProfile.ROLE_REALM_OWNER,
|
|
|
|
force_date_joined=installation_time,
|
|
|
|
)
|
2021-04-09 02:29:05 +02:00
|
|
|
do_change_user_role(shylock, UserProfile.ROLE_REALM_OWNER, acting_user=None)
|
2022-07-13 20:44:28 +02:00
|
|
|
|
2022-10-10 21:22:46 +02:00
|
|
|
# Create guest user for set_guest_users_statistic.
|
|
|
|
create_user(
|
|
|
|
"bassanio@analytics.ds",
|
|
|
|
"Bassanio",
|
|
|
|
realm,
|
|
|
|
full_name="Bassanio",
|
|
|
|
role=UserProfile.ROLE_GUEST,
|
|
|
|
force_date_joined=installation_time,
|
|
|
|
)
|
|
|
|
|
2024-04-02 18:39:18 +02:00
|
|
|
administrators_user_group = NamedUserGroup.objects.get(
|
2023-09-21 13:06:39 +02:00
|
|
|
name=SystemGroups.ADMINISTRATORS, realm=realm, is_system_group=True
|
2022-07-13 20:44:28 +02:00
|
|
|
)
|
|
|
|
stream = Stream.objects.create(
|
|
|
|
name="all",
|
|
|
|
realm=realm,
|
|
|
|
date_created=installation_time,
|
|
|
|
can_remove_subscribers_group=administrators_user_group,
|
|
|
|
)
|
2019-02-03 06:35:11 +01:00
|
|
|
recipient = Recipient.objects.create(type_id=stream.id, type=Recipient.STREAM)
|
2019-11-28 16:56:04 +01:00
|
|
|
stream.recipient = recipient
|
|
|
|
stream.save(update_fields=["recipient"])
|
2019-02-03 06:35:11 +01:00
|
|
|
|
|
|
|
# Subscribe shylock to the stream to avoid invariant failures.
|
2023-04-19 21:31:09 +02:00
|
|
|
Subscription.objects.create(
|
|
|
|
recipient=recipient,
|
|
|
|
user_profile=shylock,
|
|
|
|
is_user_active=shylock.is_active,
|
|
|
|
color=STREAM_ASSIGNMENT_COLORS[0],
|
|
|
|
)
|
|
|
|
RealmAuditLog.objects.create(
|
|
|
|
realm=realm,
|
|
|
|
modified_user=shylock,
|
|
|
|
modified_stream=stream,
|
|
|
|
event_last_message_id=0,
|
|
|
|
event_type=RealmAuditLog.SUBSCRIPTION_CREATED,
|
|
|
|
event_time=installation_time,
|
|
|
|
)
|
2017-01-16 20:25:06 +01:00
|
|
|
|
2022-09-30 15:24:39 +02:00
|
|
|
# Create an attachment in the database for set_storage_space_used_statistic.
|
|
|
|
IMAGE_FILE_PATH = static_path("images/test-images/checkbox.png")
|
|
|
|
file_info = os.stat(IMAGE_FILE_PATH)
|
|
|
|
file_size = file_info.st_size
|
|
|
|
with open(IMAGE_FILE_PATH, "rb") as fp:
|
2023-02-28 04:02:25 +01:00
|
|
|
upload_message_attachment_from_request(UploadedFile(fp), shylock, file_size)
|
2022-09-30 15:24:39 +02:00
|
|
|
|
2023-08-02 23:53:10 +02:00
|
|
|
FixtureData: TypeAlias = Mapping[Union[str, int, None], List[int]]
|
2021-07-27 09:39:13 +02:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
def insert_fixture_data(
|
2021-07-25 15:28:47 +02:00
|
|
|
stat: CountStat,
|
2021-07-27 09:39:13 +02:00
|
|
|
fixture_data: FixtureData,
|
2021-07-25 15:28:47 +02:00
|
|
|
table: Type[BaseCount],
|
2021-02-12 08:19:30 +01:00
|
|
|
) -> None:
|
|
|
|
end_times = time_range(
|
2023-07-22 00:34:11 +02:00
|
|
|
last_end_time, last_end_time, stat.frequency, len(next(iter(fixture_data.values())))
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2018-05-18 02:16:29 +02:00
|
|
|
if table == InstallationCount:
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
id_args: Dict[str, Any] = {}
|
2017-01-16 20:25:06 +01:00
|
|
|
if table == RealmCount:
|
2021-02-12 08:20:45 +01:00
|
|
|
id_args = {"realm": realm}
|
2017-01-16 20:25:06 +01:00
|
|
|
if table == UserCount:
|
2021-02-12 08:20:45 +01:00
|
|
|
id_args = {"realm": realm, "user": shylock}
|
2017-04-03 17:13:42 +02:00
|
|
|
if table == StreamCount:
|
2021-02-12 08:20:45 +01:00
|
|
|
id_args = {"stream": stream, "realm": realm}
|
2017-04-03 17:13:42 +02:00
|
|
|
|
2017-01-16 20:25:06 +01:00
|
|
|
for subgroup, values in fixture_data.items():
|
2023-09-05 20:25:23 +02:00
|
|
|
table._default_manager.bulk_create(
|
2021-02-12 08:19:30 +01:00
|
|
|
table(
|
|
|
|
property=stat.property,
|
|
|
|
subgroup=subgroup,
|
|
|
|
end_time=end_time,
|
|
|
|
value=value,
|
|
|
|
**id_args,
|
|
|
|
)
|
|
|
|
for end_time, value in zip(end_times, values)
|
|
|
|
if value != 0
|
|
|
|
)
|
2017-01-07 04:21:34 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["1day_actives::day"]
|
2021-07-27 09:39:13 +02:00
|
|
|
realm_data: FixtureData = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 0.08, 0.02, 3, 0.3, 6, partial_sum=True),
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
}
|
2018-03-18 22:02:46 +01:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2021-07-27 09:39:13 +02:00
|
|
|
installation_data: FixtureData = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 0.8, 0.2, 4, 0.3, 6, partial_sum=True),
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
}
|
2018-05-19 22:43:02 +02:00
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2018-03-18 22:02:46 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["7day_actives::day"]
|
2020-08-07 13:39:50 +02:00
|
|
|
realm_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 0.2, 0.07, 3, 0.3, 6, partial_sum=True),
|
2020-08-07 13:39:50 +02:00
|
|
|
}
|
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
|
|
|
installation_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 2, 0.7, 4, 0.3, 6, partial_sum=True),
|
2020-08-07 13:39:50 +02:00
|
|
|
}
|
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2020-08-07 13:39:50 +02:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["realm_active_humans::day"]
|
2017-01-16 20:59:00 +01:00
|
|
|
realm_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 0.8, 0.08, 3, 0.5, 3, partial_sum=True),
|
2018-05-19 22:43:02 +02:00
|
|
|
}
|
2017-01-16 20:25:06 +01:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2018-05-18 02:16:29 +02:00
|
|
|
installation_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 1, 0.3, 4, 0.5, 3, partial_sum=True),
|
2018-05-19 22:43:02 +02:00
|
|
|
}
|
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2018-05-19 22:43:02 +02:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["active_users_audit:is_bot:day"]
|
2018-05-19 22:43:02 +02:00
|
|
|
realm_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 1, 0.2, 3.5, 0.8, 2, partial_sum=True),
|
|
|
|
"true": self.generate_fixture_data(stat, 0.3, 0.05, 3, 0.3, 2, partial_sum=True),
|
2018-05-19 22:43:02 +02:00
|
|
|
}
|
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
|
|
|
installation_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 3, 1, 4, 0.8, 2, partial_sum=True),
|
|
|
|
"true": self.generate_fixture_data(stat, 1, 0.4, 4, 0.8, 2, partial_sum=True),
|
2018-05-19 22:43:02 +02:00
|
|
|
}
|
2018-05-18 02:16:29 +02:00
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2017-01-16 20:59:00 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["messages_sent:is_bot:hour"]
|
2021-07-27 09:39:13 +02:00
|
|
|
user_data: FixtureData = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 2, 1, 1.5, 0.6, 8, holiday_rate=0.1),
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, user_data, UserCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
realm_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 35, 15, 6, 0.6, 4),
|
|
|
|
"true": self.generate_fixture_data(stat, 15, 15, 3, 0.4, 2),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
installation_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 350, 150, 6, 0.6, 4),
|
|
|
|
"true": self.generate_fixture_data(stat, 150, 150, 3, 0.4, 2),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2018-05-18 02:16:29 +02:00
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2017-01-16 20:59:00 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["messages_sent:message_type:day"]
|
2017-01-16 20:59:00 +01:00
|
|
|
user_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"public_stream": self.generate_fixture_data(stat, 1.5, 1, 3, 0.6, 8),
|
|
|
|
"private_message": self.generate_fixture_data(stat, 0.5, 0.3, 1, 0.6, 8),
|
|
|
|
"huddle_message": self.generate_fixture_data(stat, 0.2, 0.2, 2, 0.6, 8),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, user_data, UserCount)
|
|
|
|
realm_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"public_stream": self.generate_fixture_data(stat, 30, 8, 5, 0.6, 4),
|
|
|
|
"private_stream": self.generate_fixture_data(stat, 7, 7, 5, 0.6, 4),
|
|
|
|
"private_message": self.generate_fixture_data(stat, 13, 5, 5, 0.6, 4),
|
|
|
|
"huddle_message": self.generate_fixture_data(stat, 6, 3, 3, 0.6, 4),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2018-05-18 02:16:29 +02:00
|
|
|
installation_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"public_stream": self.generate_fixture_data(stat, 300, 80, 5, 0.6, 4),
|
|
|
|
"private_stream": self.generate_fixture_data(stat, 70, 70, 5, 0.6, 4),
|
|
|
|
"private_message": self.generate_fixture_data(stat, 130, 50, 5, 0.6, 4),
|
|
|
|
"huddle_message": self.generate_fixture_data(stat, 60, 30, 3, 0.6, 4),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2018-05-18 02:16:29 +02:00
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2017-01-16 20:59:00 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
website, created = Client.objects.get_or_create(name="website")
|
|
|
|
old_desktop, created = Client.objects.get_or_create(name="desktop app Linux 0.3.7")
|
|
|
|
android, created = Client.objects.get_or_create(name="ZulipAndroid")
|
|
|
|
iOS, created = Client.objects.get_or_create(name="ZulipiOS")
|
|
|
|
react_native, created = Client.objects.get_or_create(name="ZulipMobile")
|
2024-05-23 16:06:02 +02:00
|
|
|
flutter, created = Client.objects.get_or_create(name="ZulipFlutter")
|
2021-02-12 08:20:45 +01:00
|
|
|
API, created = Client.objects.get_or_create(name="API: Python")
|
|
|
|
zephyr_mirror, created = Client.objects.get_or_create(name="zephyr_mirror")
|
|
|
|
unused, created = Client.objects.get_or_create(name="unused")
|
|
|
|
long_webhook, created = Client.objects.get_or_create(name="ZulipLooooooooooongNameWebhook")
|
2017-01-16 20:59:00 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["messages_sent:client:day"]
|
2017-01-16 20:59:00 +01:00
|
|
|
user_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
website.id: self.generate_fixture_data(stat, 2, 1, 1.5, 0.6, 8),
|
|
|
|
zephyr_mirror.id: self.generate_fixture_data(stat, 0, 0.3, 1.5, 0.6, 8),
|
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, user_data, UserCount)
|
|
|
|
realm_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
website.id: self.generate_fixture_data(stat, 30, 20, 5, 0.6, 3),
|
|
|
|
old_desktop.id: self.generate_fixture_data(stat, 5, 3, 8, 0.6, 3),
|
|
|
|
android.id: self.generate_fixture_data(stat, 5, 5, 2, 0.6, 3),
|
|
|
|
iOS.id: self.generate_fixture_data(stat, 5, 5, 2, 0.6, 3),
|
|
|
|
react_native.id: self.generate_fixture_data(stat, 5, 5, 10, 0.6, 3),
|
2024-05-23 16:06:02 +02:00
|
|
|
flutter.id: self.generate_fixture_data(stat, 5, 5, 10, 0.6, 3),
|
2021-02-12 08:19:30 +01:00
|
|
|
API.id: self.generate_fixture_data(stat, 5, 5, 5, 0.6, 3),
|
|
|
|
zephyr_mirror.id: self.generate_fixture_data(stat, 1, 1, 3, 0.6, 3),
|
2017-02-09 02:55:18 +01:00
|
|
|
unused.id: self.generate_fixture_data(stat, 0, 0, 0, 0, 0),
|
2021-02-12 08:19:30 +01:00
|
|
|
long_webhook.id: self.generate_fixture_data(stat, 5, 5, 2, 0.6, 3),
|
|
|
|
}
|
2017-01-16 20:59:00 +01:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2018-05-18 02:16:29 +02:00
|
|
|
installation_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
website.id: self.generate_fixture_data(stat, 300, 200, 5, 0.6, 3),
|
|
|
|
old_desktop.id: self.generate_fixture_data(stat, 50, 30, 8, 0.6, 3),
|
|
|
|
android.id: self.generate_fixture_data(stat, 50, 50, 2, 0.6, 3),
|
|
|
|
iOS.id: self.generate_fixture_data(stat, 50, 50, 2, 0.6, 3),
|
2024-05-23 16:06:02 +02:00
|
|
|
flutter.id: self.generate_fixture_data(stat, 5, 5, 10, 0.6, 3),
|
2021-02-12 08:19:30 +01:00
|
|
|
react_native.id: self.generate_fixture_data(stat, 5, 5, 10, 0.6, 3),
|
|
|
|
API.id: self.generate_fixture_data(stat, 50, 50, 5, 0.6, 3),
|
|
|
|
zephyr_mirror.id: self.generate_fixture_data(stat, 10, 10, 3, 0.6, 3),
|
2018-05-18 02:16:29 +02:00
|
|
|
unused.id: self.generate_fixture_data(stat, 0, 0, 0, 0, 0),
|
2021-02-12 08:19:30 +01:00
|
|
|
long_webhook.id: self.generate_fixture_data(stat, 50, 50, 2, 0.6, 3),
|
|
|
|
}
|
2018-05-18 02:16:29 +02:00
|
|
|
insert_fixture_data(stat, installation_data, InstallationCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2017-01-16 20:59:00 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["messages_in_stream:is_bot:day"]
|
2021-02-12 08:19:30 +01:00
|
|
|
realm_data = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 30, 5, 6, 0.6, 4),
|
|
|
|
"true": self.generate_fixture_data(stat, 20, 2, 3, 0.2, 3),
|
2021-02-12 08:19:30 +01:00
|
|
|
}
|
2017-04-03 17:13:42 +02:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2021-07-25 15:28:47 +02:00
|
|
|
stream_data: Mapping[Union[int, str, None], List[int]] = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"false": self.generate_fixture_data(stat, 10, 7, 5, 0.6, 4),
|
|
|
|
"true": self.generate_fixture_data(stat, 5, 3, 2, 0.4, 2),
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
}
|
2017-04-03 17:13:42 +02:00
|
|
|
insert_fixture_data(stat, stream_data, StreamCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|
2020-06-08 08:32:22 +02:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
stat = COUNT_STATS["messages_read::hour"]
|
2020-06-08 08:32:22 +02:00
|
|
|
user_data = {
|
2021-02-12 08:19:30 +01:00
|
|
|
None: self.generate_fixture_data(stat, 7, 3, 2, 0.6, 8, holiday_rate=0.1),
|
2020-06-08 08:32:22 +02:00
|
|
|
}
|
|
|
|
insert_fixture_data(stat, user_data, UserCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
realm_data = {None: self.generate_fixture_data(stat, 50, 35, 6, 0.6, 4)}
|
2020-06-08 08:32:22 +02:00
|
|
|
insert_fixture_data(stat, realm_data, RealmCount)
|
2021-02-12 08:19:30 +01:00
|
|
|
FillState.objects.create(
|
|
|
|
property=stat.property, end_time=last_end_time, state=FillState.DONE
|
|
|
|
)
|