Skip to content

Conversation

@TillJohanndeiter
Copy link

fixes #568

Add an option to set the OfflineFirstGetPolicy for associations. As described before i experienced performance issues if i use alwaysHydrate with Model that have (nested) associations. So i added here an optional parameter to specify the policy for associations.

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

Copy link
Collaborator

@tshedor tshedor left a comment

Choose a reason for hiding this comment

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

@TillJohanndeiter Thank you for opening this PR. Could you please add tests for this too to the brick_offline_first package?

@tshedor tshedor changed the title Set policy for associations feat(offline_first): set policy for associations Apr 9, 2025
Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ The following Jit checks failed to run:

  • secret-detection

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ The following Jit checks failed to run:

  • secret-detection

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ The following Jit checks failed to run:

  • secret-detection

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

get<TModel>(
query: query,
policy: policy,
associationPolicy: associationPolicy,).then(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like it's missing a formatting check

}) async {
return Horse(
name: data['name'] as String?,
mounties: await Future.wait<Mounty>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this removed?

this.name,
this.mounties = const <Mounty>[],
});
final Owner? owner;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of adding another model, why can't the existing Mounty be used?

final localResults = await sqliteProvider.get<TModel>(repository: this);
final remoteResults =
await get<TModel>(query: query, policy: OfflineFirstGetPolicy.awaitRemote);
await get<TModel>(query: query, policy: OfflineFirstGetPolicy.awaitRemote, associationPolicy: associationPolicy);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both OfflineFirstWithRestRepository and OfflineFirstWithGraphqlRepository need to be updated

@override
Future<List<TModel>> get<TModel extends TRepositoryModel>({
OfflineFirstGetPolicy policy = OfflineFirstGetPolicy.awaitRemoteWhenNoneExist,
OfflineFirstGetPolicy? associationPolicy,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new parameter requires doc comments on this get method

/// can be expensive for large datasets, making deserialization a significant hit when the result
/// is ignorable (e.g. eager loading). Defaults to `false`.
Future<List<TModel>> getBatched<TModel extends TRepositoryModel>({
OfflineFirstGetPolicy? associationPolicy,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here - this will need documentation

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

OfflineFirstGetPolicy alwaysHydrate is unexpectedly slow

2 participants