Skip to content

change-history-backup#206

Open
Nikunjsharma0 wants to merge 29 commits into
mainfrom
change-history-backup
Open

change-history-backup#206
Nikunjsharma0 wants to merge 29 commits into
mainfrom
change-history-backup

Conversation

@Nikunjsharma0

Copy link
Copy Markdown
Collaborator

No description provided.

Nikunjsharma0 and others added 18 commits March 12, 2026 11:43
# Conflicts:
#	respect-datalayer-db/schemas/world.respect.datalayer.db.RespectSchoolDatabase/12.json
#	respect-datalayer-db/src/commonMain/kotlin/world/respect/datalayer/db/RespectSchoolDatabase.kt
#	respect-datalayer-db/src/commonMain/kotlin/world/respect/datalayer/db/RespectSchoolDatabaseMigrations.kt
#	respect-datalayer-db/src/commonMain/kotlin/world/respect/datalayer/db/SchoolDataSourceDb.kt
#	respect-datalayer-http/src/commonMain/kotlin/world/respect/datalayer/http/SchoolDataSourceHttp.kt
#	respect-datalayer-repository/src/commonMain/kotlin/world/respect/datalayer/repository/SchoolDataSourceRepository.kt
#	respect-datalayer-repository/src/commonMain/kotlin/world/respect/datalayer/repository/school/writequeue/DrainRemoteWriteQueueUseCase.kt
#	respect-datalayer/src/commonMain/kotlin/world/respect/datalayer/SchoolDataSource.kt
#	respect-datalayer/src/commonMain/kotlin/world/respect/datalayer/SchoolDataSourceLocal.kt
#	respect-datalayer/src/commonMain/kotlin/world/respect/datalayer/school/writequeue/WriteQueueItem.kt
@poojaustad poojaustad linked an issue Mar 25, 2026 that may be closed by this pull request
@Nikunjsharma0

Copy link
Copy Markdown
Collaborator Author

its ready for review


if (historyGuidHashes.isEmpty()) return

schoolDb.getChangeHistoryDao().markByHistoryGuids(historyGuidHashes) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what on earth is that closing bracket doing over there? Please... Tidy it.

import world.respect.datalayer.school.model.ChangeHistoryTableEnum

interface ChangeHistoryProvider {
suspend fun getChangeHistoryEntries(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would get only pending to send to server change history entries, correct? In which case, should be renamed accordingly (e.g. getPendingChangeHistoryEntries)


changeHistoryFlow.collect { state ->

val changeHistoryList = state.dataOrNull()?.map { entry ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sorting should be done in the database using Sort by in the SQL.

) : RespectViewModel(savedStateHandle), KoinScopeComponent {
private val schoolDataSource: SchoolDataSource by inject()

override val scope: Scope = accountManager.requireActiveAccountScope()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope must go before use of inject, otherwise results can be unpredictable.

prev.copy(
showAddStudent = selectedAccountAndPerson?.person?.isAdminOrTeacher() == true,
showAddTeacher = selectedAccountAndPerson?.person?.isAdminOrTeacher() == true,
changeHistoryButtonVisible = hasReadPermission,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed and does not make sense. If a person does not have read permission, they shouldn't be on this screen. And the datasource will enforce that they won't be able to read the class entity itself.

permissionsRequiredByRole = CheckPersonPermissionUseCase.PermissionsRequiredByRole.WRITE_PERMISSIONS,
)

val hasReadPermission = checkPersonPermissionUseCase(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as per comment on class: this check does not make sense.

when (val incoming = call.receive<JsonElement>()) {

is JsonArray -> {
val clazz = Json.decodeFromJsonElement<List<Clazz>>(incoming)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use json from the dependency injectoin

)
val schoolDataSource = schoolDataSource(call)

when (val incoming = call.receive<JsonElement>()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nikunjsharma0 #yellow this is a case of failure to follow Don't Repeat Youself principles as per code guidelines.

You should not have three copies of exactly the same logic. This must be done using an extension function or some other suitable code reuse mechanism.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. something like:

fun <T> ApplicationCall.receiveDataAndChangeHistory(
   deserializer: DeserializationStrategy<T> 
): DataAndChangeHistory<T> {
 when...
}

@mikedawson mikedawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change history

3 participants