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

Remove short ID #2148

Merged
merged 25 commits into from
Feb 1, 2024
Merged

Remove short ID #2148

merged 25 commits into from
Feb 1, 2024

Conversation

TheSlimvReal
Copy link
Collaborator

@TheSlimvReal TheSlimvReal commented Jan 2, 2024

closes: #1526

  • (fully?) remove usage of short ID
  • adjust PouchDB views
  • URL supports both ways, using short ID though
  • change reference to enum in additional property of schema
  • remove addPrefix query function and toEntities(...)' prefix variable - REQUIRES MIGRATION

Copy link

github-actions bot commented Jan 2, 2024

Deployed to https://pr-2148.aam-digital.net/

Copy link
Member

@sleidig sleidig left a comment

Choose a reason for hiding this comment

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

this looks pretty good to me!
Not sure how far the indexing still has problems or what tasks remain open?

Not functionally tested yet.

src/app/child-dev-project/children/children.service.ts Outdated Show resolved Hide resolved
Comment on lines -77 to +76
emit(["${School.ENTITY_TYPE}:" + doc.schoolId, start]);
emit([doc.childId, start]);
Copy link
Member

Choose a reason for hiding this comment

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

which needs to come first: the migration of data or the update of these index definitions? would these indices still work in old or new form with both migrated and previous data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we update and migrate at the same time, the user will most likely get the data before getting the app update which means it doesn't matter if we support both formats here.
On the other side I don't think we can make the code work with both the new and old data format as this is exactly why we decided for the migration.

Comment on lines 40 to 41
// TODO or de we rather want to pass full IDs around here as well?
const entityId = Entity.createPrefixedId(ConfigurableEnum.ENTITY_TYPE, id);
Copy link
Member

Choose a reason for hiding this comment

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

good question ... would be redundant, as the dataType already makes it clear. But if that makes it much easier to implement ...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the moment it wouldn't add a benefit to migrate it. But the question is more if we want to keep it consistent (full ID whenever possible)

Comment on lines 92 to 97
// TODO should this be migrated?
const schemaFields = [...entity.schema.entries()]
.filter(
([_, schema]) =>
schema.innerDataType === this.enumEntity.getId() ||
schema.additional === this.enumEntity.getId(),
schema.innerDataType === this.enumEntity.getId(true) ||
schema.additional === this.enumEntity.getId(true),
Copy link
Member

Choose a reason for hiding this comment

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

yes, maybe. Could be a point when we introduce a dataType for enum-multi/-array (#2121)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean a select field where values from multiple configurable enums can be selected?

public getId(withPrefix: boolean = false): string {
if (withPrefix) return this._id;
return this.entityId;
public getId(withoutPrefix = false): string {
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to switch the default value instead of the meaning of the param (i.e. getId(withPrefix = true)) - at least for people who have used the previous system this seems the safer, less confusing way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But this introduces the problem that the check if (withPrefix) would be false if no argument is passed. So I think the saver and generally more common approach would be that passing no argument or passing a false argument results in the same output.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that would mean not passing the param is different from passing false - but if the expected standard is to get it with prefix and explicitly passing false disables that, in my opinion that is as explicit as the other way round.
I am not insisting on this though - it mostly confused me during review here but I'll get used to the new way quickly.

Copy link
Member

@sleidig sleidig left a comment

Choose a reason for hiding this comment

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

Looks good to me now!

I did a general walkthrough of the pr deployed app, looking at references and lists. Didn't notice any issues there functionally.

I guess the last open point is whether we do something special for aligning update + migration. And some test still failing?

TheSlimvReal and others added 8 commits January 16, 2024 09:59
# Conflicts:
#	src/app/child-dev-project/schools/child-school-overview/child-school-overview.component.ts
#	src/app/core/common-components/entity-form/entity-form.service.spec.ts
#	src/app/core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component.spec.ts
#	src/app/core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component.ts
#	src/app/core/filter/filters/filters.ts
@sleidig
Copy link
Member

sleidig commented Jan 22, 2024

Tested deployed version on dev.aam-digital.net with the migration from Aam-Digital/ndb-admin#18 that you already applied:

  • on previous version (3.29.0) no errors or complete breakdowns happen, only the related-entities tables remain empty. I think that is a good and smooth experience for users during the upgrade.
  • upon deploying the pre-release, the app did reload automatically to load the new version, as expected
  • with the version from this PR here, related entities are displayed again as expected and creating new entries also works
  • Education History (from Child + School)
  • ASER
  • Matching
  • Attendance
  • (!) Todos: Cannot read properties of undefined (reading 'completedBy' ...
  • (!) Notes + Todos: cannot create new from tab -> '+' button not working in TodosRelatedToEntity and NotesRelatedToEntity #2188
  • Health (only updates after reload --> bug in master)
  • Educational Material
  • Observations (only updates after reload --> bug in master)

I'll look into the "update only on reload" issue separately.

Except the Notes/Todos bug things seem to work very well. (some unit test failing, however)

@TheSlimvReal TheSlimvReal marked this pull request as ready for review January 22, 2024 10:49
# Conflicts:
#	src/app/child-dev-project/notes/notes-related-to-entity/notes-related-to-entity.component.ts
#	src/app/features/todos/todos-related-to-entity/todos-related-to-entity.component.ts
@TheSlimvReal TheSlimvReal merged commit f86ca9d into master Feb 1, 2024
6 of 7 checks passed
@TheSlimvReal TheSlimvReal deleted the remove_short_id branch February 1, 2024 12:30
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.31.0-master.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released on @master managed by CI (semantic-release) label Feb 1, 2024
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.31.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released managed by CI (semantic-release) label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @master managed by CI (semantic-release) released managed by CI (semantic-release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor getId() function
3 participants