mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
remote-activity: Format no mobile push data as zero for remote server.
This commit is contained in:
committed by
Tim Abbott
parent
9197a2c3e2
commit
2e7715e522
@@ -51,7 +51,7 @@ def make_table(
|
||||
def fix_rows(
|
||||
rows: List[List[Any]],
|
||||
i: int,
|
||||
fixup_func: Union[Callable[[str], Markup], Callable[[datetime], str]],
|
||||
fixup_func: Union[Callable[[str], Markup], Callable[[datetime], str], Callable[[int], int]],
|
||||
) -> None:
|
||||
for row in rows:
|
||||
row[i] = fixup_func(row[i])
|
||||
@@ -79,6 +79,13 @@ def format_date_for_activity_reports(date: Optional[datetime]) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def format_none_as_zero(value: Optional[int]) -> int:
|
||||
if value:
|
||||
return value
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def user_activity_link(email: str, user_profile_id: int) -> Markup:
|
||||
from analytics.views.user_activity import get_user_activity
|
||||
|
||||
|
@@ -5,6 +5,7 @@ from psycopg2.sql import SQL
|
||||
from analytics.views.activity_common import (
|
||||
fix_rows,
|
||||
format_date_for_activity_reports,
|
||||
format_none_as_zero,
|
||||
get_query_data,
|
||||
make_table,
|
||||
remote_installation_stats_link,
|
||||
@@ -122,6 +123,8 @@ def get_remote_server_activity(request: HttpRequest) -> HttpResponse:
|
||||
for i, col in enumerate(cols):
|
||||
if col == "Last update time":
|
||||
fix_rows(rows, i, format_date_for_activity_reports)
|
||||
if col in ["Mobile users", "Mobile pushes forwarded"]:
|
||||
fix_rows(rows, i, format_none_as_zero)
|
||||
if i == 0:
|
||||
total_row.append("Total")
|
||||
elif i in totals_columns:
|
||||
|
Reference in New Issue
Block a user