mirror of https://github.com/zulip/zulip.git
user_topics: Refactor the construction loop for UserTopicDict.
This ensures type safety by not mutating the original queryset values, that django-stubs to type as a TypedDict without total=False. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
1d7abb3f5d
commit
4f4d61cb59
|
@ -43,11 +43,17 @@ def get_user_topics(
|
|||
|
||||
result = []
|
||||
for row in rows:
|
||||
if not include_stream_name:
|
||||
del row["stream__name"]
|
||||
user_topic_dict: UserTopicDict = {
|
||||
"stream_id": row["stream_id"],
|
||||
"topic_name": row["topic_name"],
|
||||
"visibility_policy": row["visibility_policy"],
|
||||
"last_updated": datetime_to_timestamp(row["last_updated"]),
|
||||
}
|
||||
|
||||
row["last_updated"] = datetime_to_timestamp(row["last_updated"])
|
||||
result.append(row)
|
||||
if include_stream_name:
|
||||
user_topic_dict["stream__name"] = row["stream__name"]
|
||||
|
||||
result.append(user_topic_dict)
|
||||
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue