Skip to content

Commit

Permalink
fix: Soft delete language issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Jul 30, 2024
1 parent 25262d7 commit c0e8beb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
11 changes: 0 additions & 11 deletions backend/data/src/main/kotlin/io/tolgee/model/Language.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import jakarta.persistence.OneToMany
import jakarta.persistence.OneToOne
import jakarta.persistence.PrePersist
import jakarta.persistence.Table
import jakarta.persistence.UniqueConstraint
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.Size
Expand All @@ -31,16 +30,6 @@ import java.util.*
@Entity
@EntityListeners(Language.Companion.LanguageListeners::class)
@Table(
uniqueConstraints = [
UniqueConstraint(
columnNames = ["project_id", "name"],
name = "language_project_name",
),
UniqueConstraint(
columnNames = ["project_id", "tag"],
name = "language_tag_name",
),
],
indexes = [
Index(
columnList = "tag",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface LanguageStatsRepository : JpaRepository<LanguageStats, Long> {
ls.reviewedPercentage
)
from LanguageStats ls
where ls.language.project.id in :projectIds
where ls.language.project.id in :projectIds and ls.language.deletedAt is null
""",
)
fun getDtosByProjectIds(projectIds: List<Long>): List<LanguageStatsDto>
Expand All @@ -45,7 +45,7 @@ interface LanguageStatsRepository : JpaRepository<LanguageStats, Long> {
from LanguageStats ls
join fetch ls.language l
join fetch l.project
where l.project.id in :projectIds
where l.project.id in :projectIds and l.deletedAt is null
""",
)
fun getAllByProjectIds(projectIds: List<Long>): List<LanguageStats>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LanguageStatsService(
val translatedOrReviewedKeys = rawLanguageStats.translatedKeys + rawLanguageStats.reviewedKeys
val translatedOrReviewedWords = rawLanguageStats.translatedWords + rawLanguageStats.reviewedWords
val untranslatedWords = baseWords - translatedOrReviewedWords
val language = languages.find { it.id == rawLanguageStats.languageId } ?: return@tx
val language = languages.find { it.id == rawLanguageStats.languageId } ?: return@forEach
val stats =
languageStats.computeIfAbsent(language.id) {
LanguageStats(entityManager.getReference(Language::class.java, language.id))
Expand Down
8 changes: 8 additions & 0 deletions backend/data/src/main/resources/db/changelog/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3418,4 +3418,12 @@
<changeSet author="huglx (generated)" id="1718704326054-19">
<addForeignKeyConstraint baseColumnNames="project_id" baseTableName="slack_config" constraintName="FKsgau8dxyxblao9sa16fnka0t1" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="project" validate="true"/>
</changeSet>
<changeSet author="jenik (generated)" id="1722332220500-1">
<dropUniqueConstraint constraintName="language_project_name" tableName="language"/>
<dropUniqueConstraint constraintName="language_tag_name" tableName="language"/>
<sql>
create unique index language_project_name on language (project_id, name) where deleted_at is null;
create unique index language_tag_name on language (tag, name) where deleted_at is null;
</sql>
</changeSet>
</databaseChangeLog>
3 changes: 1 addition & 2 deletions gradle/liquibase.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ ext {
"billing_sequence," +
"activity_sequence," +
"FK9xs5a07fba5yqje5jqm6qrehs," +
"column:textsearchable_.*" +
"column:enabled_features,"+
"table:temp_*"
"table:temp_unsuccessful_job_keys"
}
}
}
Expand Down

0 comments on commit c0e8beb

Please sign in to comment.