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 - set stats on translation crea…
…te/update
- Loading branch information
Showing
5 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...nd/data/src/main/kotlin/io/tolgee/jobs/migration/translationStats/TranslationProcessor.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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package io.tolgee.jobs.migration.translationStats | ||
|
||
import io.tolgee.util.WordCounter | ||
import io.tolgee.util.TranslationStatsUtil | ||
import org.springframework.batch.item.ItemProcessor | ||
|
||
class TranslationProcessor : ItemProcessor<StatsMigrationTranslationView, TranslationStats> { | ||
override fun process(item: StatsMigrationTranslationView): TranslationStats { | ||
return TranslationStats( | ||
id = item.id, wordCount = item.text?.let { WordCounter.countWords(it, item.languageTag) } ?: 0, | ||
characterCount = item.text?.length ?: 0 | ||
id = item.id, wordCount = TranslationStatsUtil.getWordCount(item.text, item.languageTag), | ||
characterCount = TranslationStatsUtil.getCharacterCount(item.text) | ||
) | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
backend/data/src/main/kotlin/io/tolgee/util/TranslationStatsUtil.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,11 @@ | ||
package io.tolgee.util | ||
|
||
object TranslationStatsUtil { | ||
fun getWordCount(text: String?, languageTag: String): Int { | ||
return text?.let { WordCounter.countWords(it, languageTag) } ?: 0 | ||
} | ||
|
||
fun getCharacterCount(text: String?): Int { | ||
return text?.length ?: 0 | ||
} | ||
} |
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