Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use timezone ID instead of full VTIMEZONE in DB #1104

Open
wants to merge 5 commits into
base: main-ose
Choose a base branch
from

Conversation

ArnyminerZ
Copy link
Member

@ArnyminerZ ArnyminerZ commented Oct 25, 2024

Purpose

Currently we are storing the full VTimeZone definition in the database, even though we only use the timezone ID.
This PR aims to fix this, and only store the identifier.

Short description

  • Removed the column timezone from Collection
  • Added a new column timezoneId to Collection
  • Upgraded database version number to 15
  • Added migrations for database from 14 to 15:
    • Create the new timezoneId column.
    • Extract the timezone id from timezone, and copy it to timezoneId (if not null)
    • Remove the timezone column.

Note

We are storing the timezone id as given by the server, which may not be a valid Android Timezone. This is obviously converted later on when storing into the calendar provider, but maybe it's not a bad idea to convert it beforehand.

More information

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@ArnyminerZ ArnyminerZ linked an issue Oct 25, 2024 that may be closed by this pull request
3 tasks
@ArnyminerZ ArnyminerZ self-assigned this Oct 25, 2024
@ArnyminerZ ArnyminerZ added the refactoring Internal improvement of existing functions label Oct 25, 2024
ArnyminerZ and others added 5 commits November 11, 2024 10:21
Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
@rfc2822 rfc2822 force-pushed the 1052-use-timezone-id-instead-of-full-vtimezone-in-db branch from 497236a to b4b7bad Compare November 11, 2024 09:21
@rfc2822
Copy link
Member

rfc2822 commented Nov 11, 2024

Is there something missing for this PR yet?

@ArnyminerZ
Copy link
Member Author

Is there something missing for this PR yet?

It should be ready, I forgot to mark it as complete 😅

@ArnyminerZ ArnyminerZ marked this pull request as ready for review November 11, 2024 13:03
@rfc2822 rfc2822 requested review from sunkup and removed request for rfc2822 November 11, 2024 13:59
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

Really nice PR! A pleasure to review ;)

Can you tell me how to test the migration? I can see someone created a "Calendar with timezone" in the nextcloud test instance, but it does not have a timezone in the collections table in the database? None of the calendars does in fact, they are all NULL.

I tried to figure out how to change the collection/calendar timezone in the nextcloud interface but neither the setting in the calendar view, nor the "locale" setting for the user seems to work ...

How did you do it?

@@ -202,6 +206,10 @@ data class Collection(
}
}

if (timezoneId == null && timezone != null) {
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this does not update the timezoneId when it exists already. Is this what we want? Would we not always want to replace/update it, in case it changes on the server?

@@ -112,6 +113,26 @@ abstract class AppDatabase: RoomDatabase() {
// manual migrations

val migrations: Array<Migration> = arrayOf(
object : Migration(14, 15) {
override fun migrate(db: SupportSQLiteDatabase) {
// the timezone column has been removed, now it's timezoneId
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this a complete sentence, capitalized and punctuated or add an empty line after this one. One might think the sentence continues on the next line otherwise (I did at least).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use timezone ID instead of full VTIMEZONE in DB
3 participants