Skip to content

refactor(compass-schema): replace reflux with redux COMPASS-8797 #6656

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

Merged
merged 10 commits into from
Jan 28, 2025

Conversation

paula-stacho
Copy link
Contributor

@paula-stacho paula-stacho commented Jan 23, 2025

Description

Main changes:

  • setState calls replaced with a reducer
  • logic moved into redux thunk actions
  • components connected as needed

Side changes:

  • resultId is an uuid string (was previously calculated with Math.random)
  • more meaningful store tests

Note: still figuring out how to test the geoLayers

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

_trackSchemaAnalyzed(analysisTime, query);

dispatch(onSchemaSampled());
} catch (err: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't looked at what exactly analyzeSchema is doing with the signal, but usually aborting a signal results in promise rejection, so we probably want to check for that here so that stop and error are not dispatched at the same time? I think the usual pattern for this we use is instead of subscribing to signal, you'd check on error that it's caused by signal being aborted and then dispatch accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case analyzeSchema returns null when it's cancelled:

if (dataService.isCancelError(err)) {

the null schema is then handled by AnalysisFinishedAction. Hmm.. and I added a superfluous AnalysisCancelledAction, let me clean that up

@paula-stacho paula-stacho marked this pull request as ready for review January 24, 2025 16:04
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Looking good, left a couple comments/thoughts! This should make testing the store a lot smoother from the look of things also.

geo_data: schema ? schemaContainsGeoData(schema) : false,
analysis_time_ms: analysisTime,
});
track('Schema Analyzed', trackEvent, connectionInfoRef.current);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also I understand that it's something that's already working like this, but it might make sense to ask product if they expect that this is tracked when analysis is canceled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out! Waiting for confirmation, but we'll likely split this as part of https://jira.mongodb.org/browse/COMPASS-8818

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

A few very small comments, but otherwise looks good, nice cleanup


export const stopAnalysis = (): SchemaThunkAction<void> => {
return (dispatch, getState, { abortControllerRef }) => {
if (!abortControllerRef) return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on types and the plugin setup code this value is always there, so this check is not doing anything, what's the purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, that was supposed to check for .current, thanks for spotting!

@paula-stacho paula-stacho merged commit e41df6b into main Jan 28, 2025
33 checks passed
@paula-stacho paula-stacho deleted the COMPASS-8797 branch January 28, 2025 14:22
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.

3 participants