Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add project dashboard page #915 - add stats providing services
- Loading branch information
Showing
21 changed files
with
525 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../v2/hateoas/organization/LanguageModel.kt → .../api/v2/hateoas/language/LanguageModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...as/organization/LanguageModelAssembler.kt → ...ateoas/language/LanguageModelAssembler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/src/main/kotlin/io/tolgee/api/v2/hateoas/project/ProjectModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/src/main/kotlin/io/tolgee/api/v2/hateoas/project/ProjectWithStatsModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pp/src/main/kotlin/io/tolgee/api/v2/hateoas/translations/KeysWithTranslationsPageModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tlin/io/tolgee/api/v2/hateoas/translations/KeysWithTranslationsPagedResourcesAssembler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
backend/app/src/test/kotlin/io/tolgee/service/ProjectStatsServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.tolgee.service | ||
|
||
import io.tolgee.AbstractSpringTest | ||
import io.tolgee.development.testDataBuilder.data.ProjectStatsTestData | ||
import io.tolgee.testing.assertions.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
internal class ProjectStatsServiceTest : AbstractSpringTest() { | ||
|
||
@Autowired | ||
lateinit var projectStatsService: ProjectStatsService | ||
|
||
@Test | ||
fun getLanguageStats() { | ||
val testData = ProjectStatsTestData() | ||
testDataService.saveTestData(testData.root) | ||
val data = projectStatsService.getLanguageStats(testData.projectBuilder.self.id) | ||
assertThat(data).hasSize(3) | ||
} | ||
|
||
@Test | ||
fun getProjectStats() { | ||
val testData = ProjectStatsTestData() | ||
testDataService.saveTestData(testData.root) | ||
val data = projectStatsService.getProjectStats(testData.projectBuilder.self.id) | ||
assertThat(data.id).isPositive | ||
assertThat(data.userCount).isEqualTo(3) | ||
assertThat(data.keyCount).isEqualTo(5) | ||
assertThat(data.tagCount).isEqualTo(3) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
...d/data/src/main/kotlin/io/tolgee/development/testDataBuilder/data/ProjectStatsTestData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
package io.tolgee.development.testDataBuilder.data | ||
|
||
import io.tolgee.development.testDataBuilder.builders.ProjectBuilder | ||
import io.tolgee.model.Language | ||
import io.tolgee.model.Permission | ||
import io.tolgee.model.enums.OrganizationRoleType | ||
import io.tolgee.model.enums.TranslationState | ||
import io.tolgee.model.key.Tag | ||
|
||
class ProjectStatsTestData : BaseTestData() { | ||
lateinit var germanLanguage: Language | ||
lateinit var czechLanguage: Language | ||
|
||
init { | ||
projectBuilder.apply { | ||
|
||
addLanguages() | ||
addKeys() | ||
|
||
val organizationOwner = root.addUserAccount { | ||
name = "franta" | ||
username = "franta" | ||
}.self | ||
|
||
val organizationMember = root.addUserAccount { | ||
name = "jindra" | ||
username = "jindra" | ||
}.self | ||
|
||
root.addOrganization { | ||
name = "org" | ||
projectBuilder.self.organizationOwner = this | ||
}.build buildOrganization@{ | ||
addRole { | ||
user = organizationOwner | ||
type = OrganizationRoleType.OWNER | ||
organization = this@buildOrganization.self | ||
} | ||
addRole { | ||
user = organizationMember | ||
type = OrganizationRoleType.MEMBER | ||
organization = this@buildOrganization.self | ||
} | ||
} | ||
|
||
addPermission { | ||
type = Permission.ProjectPermissionType.MANAGE | ||
user = organizationMember | ||
} | ||
|
||
self.userOwner = null | ||
} | ||
} | ||
|
||
private fun ProjectBuilder.addLanguages() { | ||
germanLanguage = addGerman().self | ||
czechLanguage = addCzech().self | ||
} | ||
|
||
private fun ProjectBuilder.addKeys() { | ||
val tag1 = Tag().apply { | ||
name = "Tag1" | ||
project = this@addKeys.self | ||
} | ||
|
||
val tag2 = Tag().apply { | ||
name = "Tag2" | ||
project = this@addKeys.self | ||
} | ||
|
||
val tag3 = Tag().apply { | ||
name = "Tag3" | ||
project = this@addKeys.self | ||
} | ||
|
||
addKey { | ||
name = "Super key" | ||
}.build { | ||
addTranslation { | ||
language = englishLanguage | ||
text = "This text has 5 words" | ||
} | ||
addTranslation { | ||
language = germanLanguage | ||
text = "Another text" | ||
state = TranslationState.TRANSLATED | ||
} | ||
|
||
addTranslation { | ||
language = czechLanguage | ||
text = "Another text" | ||
state = TranslationState.TRANSLATED | ||
} | ||
addMeta { | ||
tags.add(tag1) | ||
tags.add(tag3) | ||
} | ||
} | ||
|
||
addKey { | ||
name = "Key with null translations" | ||
}.build { | ||
addTranslation { | ||
language = englishLanguage | ||
text = "This text has 5 words" | ||
} | ||
addMeta { | ||
tags.add(tag1) | ||
tags.add(tag2) | ||
} | ||
} | ||
|
||
addKey { | ||
name = "Key with Untranslated values" | ||
}.build { | ||
addTranslation { | ||
language = englishLanguage | ||
text = "This text has 5 words" | ||
} | ||
|
||
addTranslation { | ||
language = germanLanguage | ||
text = null | ||
state = TranslationState.UNTRANSLATED | ||
} | ||
|
||
addTranslation { | ||
language = czechLanguage | ||
text = null | ||
state = TranslationState.UNTRANSLATED | ||
} | ||
} | ||
|
||
addKey { | ||
name = "Key with reviewed values" | ||
}.build { | ||
addTranslation { | ||
language = englishLanguage | ||
text = "This text has 5 words" | ||
} | ||
addTranslation { | ||
language = germanLanguage | ||
text = null | ||
state = TranslationState.REVIEWED | ||
} | ||
|
||
addTranslation { | ||
language = czechLanguage | ||
text = null | ||
state = TranslationState.REVIEWED | ||
} | ||
} | ||
|
||
addKey { | ||
name = "Key with mixed values" | ||
}.build { | ||
addTranslation { | ||
language = englishLanguage | ||
text = "This text has 5 words" | ||
} | ||
addTranslation { | ||
language = germanLanguage | ||
text = null | ||
state = TranslationState.TRANSLATED | ||
} | ||
|
||
addTranslation { | ||
language = czechLanguage | ||
text = null | ||
state = TranslationState.REVIEWED | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...data/src/main/kotlin/io/tolgee/model/views/projectStats/ProjectLanguageStatsResultView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.tolgee.model.views.projectStats | ||
|
||
data class ProjectLanguageStatsResultView( | ||
val languageId: Long?, | ||
val languageTag: String?, | ||
val languageName: String?, | ||
val languageOriginalName: String?, | ||
val languageFlagEmoji: String?, | ||
val translatedKeys: Long?, | ||
val translatedWords: Long?, | ||
val reviewedKeys: Long?, | ||
val reviewedWords: Long?, | ||
) |
8 changes: 8 additions & 0 deletions
8
backend/data/src/main/kotlin/io/tolgee/model/views/projectStats/ProjectStatsView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.tolgee.model.views.projectStats | ||
|
||
data class ProjectStatsView( | ||
val id: Long, | ||
val keyCount: Long, | ||
val userCount: Long, | ||
val tagCount: Long | ||
) |
Oops, something went wrong.