点赞和评论

This commit is contained in:
2024-07-30 14:28:13 +08:00
parent 406caa3702
commit 0730fdea68
10 changed files with 357 additions and 93 deletions

View File

@@ -39,13 +39,14 @@ object TestDatabase {
)
var followList = emptyList<Pair<Int, Int>>()
var likeCommentList = emptyList<Pair<Int, Int>>()
var likeMomentList = emptyList<Pair<Int, Int>>()
init {
val faker = faker {
this.fakerConfig {
locale = "en"
}
}
accountData = (0..100).toList().mapIndexed { idx, _ ->
accountData = (0..20).toList().mapIndexed { idx, _ ->
AccountProfile(
id = idx,
followerCount = 0,
@@ -58,7 +59,7 @@ object TestDatabase {
)
}
// make a random follow rel
for (i in 0..500) {
for (i in 0..100) {
var person1 = accountData.random()
var persion2 = accountData.random()
followList += Pair(person1.id, persion2.id)
@@ -74,13 +75,14 @@ object TestDatabase {
}
}
momentData = (0..200).toList().mapIndexed { idx, _ ->
momentData = (0..60).toList().mapIndexed { idx, _ ->
val person = accountData.random()
// make fake comment
for (i in 0..faker.random.nextInt(0, 5)) {
val commentCount = faker.random.nextInt(0, 50)
for (i in 0..commentCount) {
commentIdCounter += 1
val commentPerson = accountData.random()
var newComment = Comment(
var newComment = Comment(
name = commentPerson.nickName,
comment = "this is comment ${commentIdCounter}",
date = "2023-02-02 11:23",
@@ -94,12 +96,17 @@ object TestDatabase {
)
// generate like comment list
for (likeIdx in 0..faker.random.nextInt(0, 5)) {
val likePerson = accountData.random()
val likePerson = accountData.random()
likeCommentList += Pair(commentIdCounter, likePerson.id)
newComment = newComment.copy(likes = newComment.likes + 1)
}
comment += newComment
}
val likeCount = faker.random.nextInt(0, 5)
for (i in 0..likeCount) {
val likePerson = accountData.random()
likeMomentList += Pair(idx, likePerson.id)
}
MomentItem(
id = idx,
avatar = person.avatar,
@@ -109,8 +116,8 @@ object TestDatabase {
followStatus = false,
momentTextContent = "By strongarming Ducati into giving him the factory seat.Marquez effectively …",
momentPicture = R.drawable.default_moment_img,
likeCount = faker.random.nextInt(0, 100),
commentCount = faker.random.nextInt(0, 100),
likeCount = likeCount,
commentCount = commentCount + 1,
shareCount = faker.random.nextInt(0, 100),
favoriteCount = faker.random.nextInt(0, 100),
images = imageList.shuffled().take(3),