feat(communities): extend community with active members count
closes: #8016
This commit is contained in:
parent
a6df4566dd
commit
b72fff3f04
|
@ -11,6 +11,7 @@ type
|
|||
color: string
|
||||
tags: string
|
||||
members: int
|
||||
activeMembers: int
|
||||
|
||||
proc initCuratedCommunityItem*(
|
||||
id: string,
|
||||
|
@ -21,7 +22,8 @@ proc initCuratedCommunityItem*(
|
|||
banner: string,
|
||||
color: string,
|
||||
tags: string,
|
||||
members: int
|
||||
members: int,
|
||||
activeMembers: int
|
||||
): CuratedCommunityItem =
|
||||
result.id = id
|
||||
result.name = name
|
||||
|
@ -32,6 +34,7 @@ proc initCuratedCommunityItem*(
|
|||
result.color = color
|
||||
result.tags = tags
|
||||
result.members = members
|
||||
result.activeMembers = activeMembers
|
||||
|
||||
proc `$`*(self: CuratedCommunityItem): string =
|
||||
result = fmt"""CuratedCommunityItem(
|
||||
|
@ -42,6 +45,7 @@ proc `$`*(self: CuratedCommunityItem): string =
|
|||
color: {self.color},
|
||||
tags: {self.tags},
|
||||
members: {self.members}
|
||||
activeMembers: {self.activeMembers}
|
||||
]"""
|
||||
|
||||
proc getId*(self: CuratedCommunityItem): string =
|
||||
|
@ -65,6 +69,9 @@ proc getBanner*(self: CuratedCommunityItem): string =
|
|||
proc getMembers*(self: CuratedCommunityItem): int =
|
||||
return self.members
|
||||
|
||||
proc getActiveMembers*(self: CuratedCommunityItem): int =
|
||||
return self.activeMembers
|
||||
|
||||
proc getColor*(self: CuratedCommunityItem): string =
|
||||
return self.color
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ type
|
|||
Banner
|
||||
Featured
|
||||
Members
|
||||
ActiveMembers
|
||||
Popularity
|
||||
Color
|
||||
Tags
|
||||
|
@ -57,6 +58,7 @@ QtObject:
|
|||
ModelRole.Banner.int:"banner",
|
||||
ModelRole.Featured.int:"featured",
|
||||
ModelRole.Members.int:"members",
|
||||
ModelRole.ActiveMembers.int:"activeMembers",
|
||||
ModelRole.Color.int:"color",
|
||||
ModelRole.Popularity.int:"popularity",
|
||||
ModelRole.Tags.int:"tags"
|
||||
|
@ -84,6 +86,8 @@ QtObject:
|
|||
result = newQVariant(item.getBanner())
|
||||
of ModelRole.Members:
|
||||
result = newQVariant(item.getMembers())
|
||||
of ModelRole.ActiveMembers:
|
||||
result = newQVariant(item.getActiveMembers())
|
||||
of ModelRole.Color:
|
||||
result = newQVariant(item.getColor())
|
||||
of ModelRole.Popularity:
|
||||
|
@ -132,6 +136,7 @@ QtObject:
|
|||
ModelRole.Banner.int,
|
||||
ModelRole.Featured.int,
|
||||
ModelRole.Members.int,
|
||||
ModelRole.ActiveMembers.int,
|
||||
ModelRole.Color.int,
|
||||
ModelRole.Popularity.int,
|
||||
ModelRole.Tags.int])
|
||||
|
|
|
@ -194,7 +194,8 @@ method getCuratedCommunityItem(self: Module, c: CommunityDto): CuratedCommunityI
|
|||
c.images.banner,
|
||||
c.color,
|
||||
c.tags,
|
||||
len(c.members))
|
||||
len(c.members),
|
||||
int(c.activeMembersCount))
|
||||
|
||||
method getDiscordCategoryItem(self: Module, c: DiscordCategoryDto): DiscordCategoryItem =
|
||||
return initDiscordCategoryItem(
|
||||
|
|
|
@ -101,6 +101,7 @@ type CommunityDto* = object
|
|||
canceledRequestsToJoin*: seq[CommunityMembershipRequestDto]
|
||||
tokenPermissions*: Table[string, CommunityTokenPermissionDto]
|
||||
communityTokensMetadata*: seq[CommunityTokensMetadataDto]
|
||||
activeMembersCount*: int64
|
||||
|
||||
proc isAvailable*(communityDto: CommunityDto): bool =
|
||||
return communityDto.name != "" and communityDto.description != ""
|
||||
|
@ -311,6 +312,7 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto =
|
|||
|
||||
discard jsonObj.getProp("requestedToJoinAt", result.requestedToJoinAt)
|
||||
discard jsonObj.getProp("muted", result.muted)
|
||||
discard jsonObj.getProp("activeMembersCount", result.activeMembersCount)
|
||||
|
||||
var communityTokensMetadataObj: JsonNode
|
||||
if(jsonObj.getProp("communityTokensMetadata", communityTokensMetadataObj) and communityTokensMetadataObj.kind == JArray):
|
||||
|
|
|
@ -71,7 +71,7 @@ StatusScrollView {
|
|||
name: model.name
|
||||
description: model.description
|
||||
members: model.members
|
||||
activeUsers: model.activeMembers ?? 0
|
||||
activeUsers: model.activeMembers
|
||||
popularity: model.popularity
|
||||
categories: tagsJson.model
|
||||
|
||||
|
|
Loading…
Reference in New Issue