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

Fix the QueriesDocument and the Queries UI #16402

Merged
merged 56 commits into from
Jul 19, 2024
Merged

Conversation

MikeAlhayek
Copy link
Member

@MikeAlhayek MikeAlhayek commented Jul 3, 2024

@MikeAlhayek MikeAlhayek marked this pull request as ready for review July 3, 2024 22:55
@MikeAlhayek MikeAlhayek requested a review from Piedone July 3, 2024 22:56
@Piedone
Copy link
Member

Piedone commented Jul 3, 2024

Why is splitting Queries into multiple documents necessary for the fix?

Also, please fix the build.

@MikeAlhayek
Copy link
Member Author

@Piedone The problem with today's approach is that it stores all different query types in the same document. So when we add, update or remove a query, we serialize/deserialize the entire document. For this to work with STJ, we have to register each query type with the base type. When the feature is disabled after a query is added to the document, we get an exception because the derived type is no longer registered with the base type.

For example, if you enable the Sql feature, then add a SqlQuery using the UI. Now enable Lucene feature and disable the Sql feature. Visiting the queries UI will throw exception because the document has a record serialized to SqlQuery but there is no map between SqlQuery to Query.

To solve this problem, we agreed to remove the document manager during last meeting and instead to store each query as a document. This way we fix the issue and also avoid using the document manager or worry about registering additional types.

@gvkries
Copy link
Contributor

gvkries commented Jul 4, 2024

Wow, what an effort. I knew why I left this to you 🤗

@hishamco hishamco changed the title Rremove the QueriesDocument Remove the QueriesDocument Jul 4, 2024
@Piedone
Copy link
Member

Piedone commented Jul 4, 2024

@Piedone The problem with today's approach is that it stores all different query types in the same document. So when we add, update or remove a query, we serialize/deserialize the entire document. For this to work with STJ, we have to register each query type with the base type. When the feature is disabled after a query is added to the document, we get an exception because the derived type is no longer registered with the base type.

For example, if you enable the Sql feature, then add a SqlQuery using the UI. Now enable Lucene feature and disable the Sql feature. Visiting the queries UI will throw exception because the document has a record serialized to SqlQuery but there is no map between SqlQuery to Query.

To solve this problem, we agreed to remove the document manager during last meeting and instead to store each query as a document. This way we fix the issue and also avoid using the document manager or worry about registering additional types.

I see, thanks for explaining!

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

I'll resume reviewing this in-depth once the exception is fixed. Also, please fix the tests.

src/docs/releases/2.0.0.md Outdated Show resolved Hide resolved
@MikeAlhayek MikeAlhayek requested a review from Piedone July 6, 2024 00:52
@MikeAlhayek
Copy link
Member Author

@Piedone the test should now pass. Feel free to check out the code changes.

Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

Would you like to check the code again, @gvkries?

@MikeAlhayek MikeAlhayek mentioned this pull request Jul 11, 2024
30 tasks
@MikeAlhayek
Copy link
Member Author

@gvkries this is the last PR that is blocking the release of 2. Do you have any additional feedback on this PR? Or, should we merge it?

Thank you

@gvkries
Copy link
Contributor

gvkries commented Jul 15, 2024

@gvkries this is the last PR that is blocking the release of 2. Do you have any additional feedback on this PR? Or, should we merge it?

Thank you

Sorry, didn't had time the last couple of days. I will check ASAP.

Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

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

The design looks good to me so far, but when I save a SQL query, I loose it. There is a bug somewhere, I did not check in detail.

image

services.AddScoped<INavigationProvider, AdminMenu>();
services.AddScoped<SqlQuerySource>();
services.AddScoped<IQuerySource>(sp => sp.GetService<SqlQuerySource>());
services.AddKeyedScoped<IQuerySource>(SqlQuerySource.SourceName, (sp, key) => sp.GetService<SqlQuerySource>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add an extension method for registering an IQuerySource, it's already repeated several times here.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@MikeAlhayek
Copy link
Member Author

@gvkries I can’t seems to be able to reproduce that query not saving issue. Are you sure you are using the latest code?

@gvkries
Copy link
Contributor

gvkries commented Jul 15, 2024

@gvkries I can’t seems to be able to reproduce that query not saving issue. Are you sure you are using the latest code?

I think so. Just create an new site with the blog recipe, go to Queries -> Edit and the SQL query gets deleted instead of modified.

src/docs/releases/2.0.0.md Outdated Show resolved Hide resolved
@MikeAlhayek
Copy link
Member Author

@gvkries I was finally able to reproduce the issue and fix it. Can you please confirm?

Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @MikeAlhayek

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.

Error when disabling Lucine or elastic search feature
4 participants