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

Add form load time to xforms and es forms mapping #34824

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Charl1996
Copy link
Contributor

@Charl1996 Charl1996 commented Jun 26, 2024

Review by commit. The vast majority of the files are test updates (the last commit), so don't panic and simply review by commit.

This PR is a duplicate of this one, but with the commit history cleaned up.

Product Description

No visible changes.

Technical Summary

Mobile ticket
HQ Ticket

A new form meta field is added, formLoadTime, which tracks how long a form takes to load. The mobile work has been done by Ahmad, while this is the HQ part.

To generate the ES migration I ran the following command:

./manage.py make_elastic_migration --update-index forms:form

Feature Flag

No specific FF

Safety Assurance

Safety story

Tested locally. Staging testing to be done.

Automated test coverage

No automated testing yet

QA Plan

No QA planned. QA will ensue as part of this PR.

Migrations

  • The migrations in this code can be safely applied first independently of the code

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

This PR contains an elastic search mapping update migration which cannot be reverted. In the event of a revert a simple comment in the mapping file should indicate that the field should be removed during the next reindex.

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@Charl1996 Charl1996 added reindex/migration Reindex or migration will be required during or before deploy product/all-users-all-environments Change impacts all users on all environments Risk: High Change affects files that have been flagged as high risk. labels Jun 26, 2024
@Charl1996 Charl1996 requested review from mkangia and AmitPhulera June 26, 2024 10:19
@Charl1996 Charl1996 mentioned this pull request Jun 26, 2024
4 tasks
@Charl1996 Charl1996 marked this pull request as ready for review June 26, 2024 10:30
@mkangia
Copy link
Contributor

mkangia commented Jun 26, 2024

Great job on getting those tests fixed so soon.

@@ -140,6 +140,9 @@
},
"username": {
"type": "keyword"
},
"formLoadTime": {
"type": "keyword"
Copy link
Contributor

Choose a reason for hiding this comment

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

@AmitPhulera
Just confirming that this is the right type for this?

This value is going to be in miliseconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AmitPhulera suggested that we think about storing this as a date field. I'm quickly finding out what the timeStart refers to. If it refers to the timestamp a user clicked to open a form, we could store the formLoadTime as a date and not a difference. The benefit of doing this is that we could later do all sorts of date queries on this field if we wanted to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @Charl1996
Whats the challenge with how it is currently?

I don't believe we can do this. I believe we need the time it took to load the form. I don't think we can get that using timeStart and any other timestamp.

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that we are storing epoch time in formLoadTime, Is that correct. If so that is a essentially a date field so it should be treated as date in the mappings unless there is a strong reason to keep it as a keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AmitPhulera

My understanding is that we are storing epoch time in formLoadTime

The value stored in this field is something like "230" or "190", which denotes the duration in milliseconds it took to load the form. It's not epoch time

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh! I see. Feel free to discard my suggestion about storing it as date.
Another question, why are we not storing it as integer then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm, I suppose integer would be better, yes.

Copy link
Contributor

@mkangia mkangia left a comment

Choose a reason for hiding this comment

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

Great work @Charl1996

Just couple of things:

  1. Lets have steps on the PR in case this needs to be reverted? I guess @AmitPhulera can guide us on it.
  2. Is this something we can take through QA as well? I guess it would be good to confirm that form submissions from different places will work well. If you are confident that all should go well and have done your own testing on staging, that is fine then.

@Charl1996
Copy link
Contributor Author

@mkangia

Is this something we can take through QA as well?

I was thinking to involve QA with this PR and only do testing on staging myself.

Lets have steps on the PR in case this needs to be reverted?
Good idea.

@AmitPhulera Would a revert require a new migration? I couldn't simply revert locally, so I'm wondering if I need to create a new migration to revert it?

@mkangia
Copy link
Contributor

mkangia commented Jun 26, 2024

I was thinking to involve QA with this PR and only do testing on staging myself.

Hey @Charl1996 not sure I understand this. Is QA with this PR or the second one?

@Charl1996
Copy link
Contributor Author

@mkangia

I was thinking to involve QA with this PR and only do testing on staging myself.

Hey @Charl1996 not sure I understand this. Is QA with this PR or the second one?

Sorry, I mistyped. I'll go through formal QA (with QA team) only on second ticket. For this one me and Ahmad is going to test ourselves.

@Charl1996
Copy link
Contributor Author

But for now, the deploy to staging is failing to migrate. Ugh

Only specify path tor new property in migration
@AmitPhulera
Copy link
Contributor

@AmitPhulera Would a revert require a new migration? I couldn't simply revert locally, so I'm wondering if I need to create a new migration to revert it?

Hey @Charl1996, Its not possible to delete the fields form mappings in an index after they are created. Only thing that can be done is adding a comment in the mappings file to remove the attribute when the next reindex happens.

@Charl1996
Copy link
Contributor Author

Update:
The plan is to change the field from keyword to integer. The way this is going to work is that I'm going to add a new field called loadTime and we'll treat the current field, formLoadTime, as deleted. This is because the process to reindex is a big lift.

This does not mean app changes and most of this PR will stay the same, but there will be some mapping to be done between ES and HQ, which I'm in the process of updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/all-users-all-environments Change impacts all users on all environments reindex/migration Reindex or migration will be required during or before deploy Risk: High Change affects files that have been flagged as high risk.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants