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

refactor(neon_framework): migrate to neon_storage #2529

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

Conversation

Leptopoda
Copy link
Member

Signed-off-by: Nikolas Rimikis [email protected]

This is temporary and the long term goal is to remove most of these classes
as the framework transitions to direct sqlite access.

Signed-off-by: Nikolas Rimikis <[email protected]>
Copy link

codecov bot commented Sep 29, 2024

Codecov Report

Attention: Patch coverage is 74.21384% with 41 lines in your changes missing coverage. Please review.

Project coverage is 28.69%. Comparing base (29f6a4b) to head (b7d8a42).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../neon_framework/lib/src/storage/neon_cache_db.dart 0.00% 13 Missing ⚠️
...es/account_repository/lib/src/account_storage.dart 85.52% 11 Missing ⚠️
...s/neon_framework/lib/src/storage/neon_data_db.dart 0.00% 10 Missing ⚠️
...eon_framework/lib/src/storage/storage_manager.dart 0.00% 6 Missing ⚠️
...age/lib/src/storage/sqlite_cookie_persistence.dart 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2529      +/-   ##
==========================================
+ Coverage   28.66%   28.69%   +0.02%     
==========================================
  Files         366      369       +3     
  Lines      136296   136370      +74     
==========================================
+ Hits        39076    39137      +61     
- Misses      97220    97233      +13     
Flag Coverage Δ *Carryforward flag
account_repository 95.92% <87.77%> (-2.85%) ⬇️
cookie_store 99.48% <ø> (ø) Carriedforward from 29f6a4b
dashboard_app 96.05% <ø> (ø)
dynamite 31.05% <ø> (ø) Carriedforward from 29f6a4b
dynamite_end_to_end_test 61.69% <ø> (ø) Carriedforward from 29f6a4b
dynamite_runtime 85.40% <ø> (ø) Carriedforward from 29f6a4b
interceptor_http_client 97.18% <ø> (ø) Carriedforward from 29f6a4b
neon_dashboard 96.05% <ø> (ø) Carriedforward from 29f6a4b
neon_framework 57.02% <9.37%> (-2.18%) ⬇️
neon_http_client 97.50% <ø> (ø) Carriedforward from 29f6a4b
neon_notifications 100.00% <ø> (ø) Carriedforward from 29f6a4b
neon_storage 88.88% <97.29%> (-5.78%) ⬇️
neon_talk 99.45% <ø> (ø) Carriedforward from 29f6a4b
nextcloud 24.26% <ø> (ø) Carriedforward from 29f6a4b
notifications_app 97.40% <ø> (ø)
notifications_push_repository 98.59% <ø> (ø)
sort_box 90.90% <ø> (ø) Carriedforward from 29f6a4b
talk_app 98.94% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ackages/neon_framework/lib/src/blocs/accounts.dart 0.00% <ø> (ø)
...ges/neon_framework/lib/src/blocs/first_launch.dart 0.00% <ø> (ø)
...n_framework/lib/src/models/app_implementation.dart 0.00% <ø> (ø)
...lib/src/settings/utils/settings_export_helper.dart 100.00% <ø> (ø)
...neon_framework/lib/src/storage/settings_store.dart 84.61% <ø> (ø)
..._framework/lib/src/storage/single_value_store.dart 100.00% <ø> (ø)
packages/neon_framework/lib/src/testing/mocks.dart 91.66% <ø> (-0.65%) ⬇️
...s/neon_framework/lib/src/utils/global_options.dart 0.00% <ø> (ø)
.../neon_framework/lib/src/utils/request_manager.dart 78.04% <100.00%> (+0.54%) ⬆️
...account_repository/lib/src/account_repository.dart 100.00% <100.00%> (ø)
... and 11 more

... and 2 files with indirect coverage changes

@Leptopoda Leptopoda changed the title refactor(neon_framework): make request cache account independent @Leptopoda refactor(neon_framework): migrate to neon_storage Sep 29, 2024
@Leptopoda Leptopoda changed the title @Leptopoda refactor(neon_framework): migrate to neon_storage refactor(neon_framework): migrate to neon_storage Sep 29, 2024
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

The name of the first commit is a bit confused. It still uses per Account caching, but simply doesn't use the class anymore.


/// Column for the [Credentials.serverURL].
@protected
static const String serverURL = 'server_urlL';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const String serverURL = 'server_urlL';
static const String serverURL = 'server_url';

Comment on lines -1340 to -1347
sqflite:
dependency: transitive
description:
name: sqflite
sha256: a43e5a27235518c03ca238e7b4732cf35eabe863a369ceba6cbefa537a66f16d
url: "https://pub.dev"
source: hosted
version: "2.3.3+1"
Copy link
Member

Choose a reason for hiding this comment

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

This is still required for Android/iOS

await database.close();
});

test('throws when unutilized', () async {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
test('throws when unutilized', () async {
test('throws when uninitialized', () async {


expect(
persistence.getValue('key'),
equals('value'),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
equals('value'),
'value',

Comment on lines +27 to +28
PRIMARY KEY("prefix","key"),
UNIQUE("key","prefix")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PRIMARY KEY("prefix","key"),
UNIQUE("key","prefix")
PRIMARY KEY("prefix", "key")

PRIMARY KEY is already UNIQUE

Comment on lines +16 to +30
/// Column for the [Credentials.serverURL].
@protected
static const String serverURL = 'server_urlL';

/// Column for the [Credentials.username].
@protected
static const String loginName = 'login_name';

/// Column for the [Credentials.appPassword].
@protected
static const String appPassword = 'app_password';

/// Column to store the active account.
@protected
static const String active = 'active';
Copy link
Member

Choose a reason for hiding this comment

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

Can you pre- or suffix these with column?

"$serverURL" TEXT NOT NULL,
"$loginName" TEXT NOT NULL,
"$appPassword" TEXT,
"$active" BOOLEAN NOT NULL DEFAULT 0,
Copy link
Member

Choose a reason for hiding this comment

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

We should store this separately as it is not really an information about the account itself.
Also there is no check that two accounts can not be active at the same time.

return credentials.build();
} on DatabaseException catch (error, stackTrace) {
_log.warning(
'Error loading cookies.',
Copy link
Member

Choose a reason for hiding this comment

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

Wrong error message (same for all other catch blocks in this class)

Copy link
Member

Choose a reason for hiding this comment

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

How does it work without the platform specific initialization?

Copy link
Member Author

Choose a reason for hiding this comment

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

The neon_storage package handles this with a conditional import/export.

export 'database_factory.dart'
if (dart.library.js_interop) '_browser_database_factory.dart'
if (dart.library.io) '_io_database_factory.dart';

We can not easily run the neon_storage tests on web but I'll verify again that this actually works.

Copy link
Member

Choose a reason for hiding this comment

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

Same here?

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

It would be great if we could have upgrade testing from old schema versions to the latest schema version. This should also include test data to ensure everything is migrated correctly.

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.

2 participants