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