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 #34819

Closed
wants to merge 15 commits into from
Closed

Add form load time to xforms #34819

wants to merge 15 commits into from

Conversation

Charl1996
Copy link
Contributor

@Charl1996 Charl1996 commented Jun 25, 2024

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

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, according to my local env, is not reversible as such.

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 requested review from mkangia and AmitPhulera June 25, 2024 15:01
@dimagimon dimagimon added reindex/migration Reindex or migration will be required during or before deploy Risk: High Change affects files that have been flagged as high risk. labels Jun 25, 2024
name=index_runtime_name('forms-20230524'),
type_='xform',
properties={
'form': {'dynamic': False, 'properties': {'#type': {'type': 'keyword'}, '@name': {'type': 'keyword'}, 'case': {'dynamic': False, 'properties': {'@case_id': {'type': 'keyword'}, '@date_modified': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, '@user_id': {'type': 'keyword'}, '@xmlns': {'type': 'keyword'}, 'case_id': {'type': 'keyword'}, 'date_modified': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'user_id': {'type': 'keyword'}, 'xmlns': {'type': 'keyword'}}}, 'meta': {'dynamic': False, 'properties': {'appVersion': {'type': 'keyword'}, 'app_build_version': {'type': 'keyword'}, 'commcare_version': {'type': 'keyword'}, 'deviceID': {'type': 'keyword'}, 'formLoadTime': {'type': 'keyword'}, 'geo_point': {'type': 'geo_point'}, 'instanceID': {'type': 'keyword'}, 'timeEnd': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'timeStart': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'userID': {'null_value': '__NULL__', 'type': 'keyword'}, 'username': {'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.

oh wow, thats something.

@@ -1504,6 +1508,7 @@ def _add_meta_2(self, form):
'{orx}instanceID',
'{cc}appVersion',
'{orx}drift',
'{orx}formLoadTime',
Copy link
Contributor

Choose a reason for hiding this comment

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

this is going to break lots of tests! Only way is fixing them.

@mkangia
Copy link
Contributor

mkangia commented Jun 25, 2024

I see this is still in draft, happy to take a look once ready for review.
I would also recommend we run this by someone who understands the ES rollout well.

properties={
'form': {'dynamic': False, 'properties': {'#type': {'type': 'keyword'}, '@name': {'type': 'keyword'}, 'case': {'dynamic': False, 'properties': {'@case_id': {'type': 'keyword'}, '@date_modified': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, '@user_id': {'type': 'keyword'}, '@xmlns': {'type': 'keyword'}, 'case_id': {'type': 'keyword'}, 'date_modified': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'user_id': {'type': 'keyword'}, 'xmlns': {'type': 'keyword'}}}, 'meta': {'dynamic': False, 'properties': {'appVersion': {'type': 'keyword'}, 'app_build_version': {'type': 'keyword'}, 'commcare_version': {'type': 'keyword'}, 'deviceID': {'type': 'keyword'}, 'formLoadTime': {'type': 'keyword'}, 'geo_point': {'type': 'geo_point'}, 'instanceID': {'type': 'keyword'}, 'timeEnd': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'timeStart': {'format': "epoch_millis||yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'userID': {'null_value': '__NULL__', 'type': 'keyword'}, 'username': {'type': 'keyword'}}}}},
},
es_versions=[],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we specify version too? We have an option to specify es_version in elastic_make_migration command, it would be helpful in keeping the changes to the current version itself. In future when we move to a newer es version then this change would automatically would be incorported in the newer mappings.

Suggested change
es_versions=[],
es_versions=[5],

@Charl1996
Copy link
Contributor Author

(patiently going through fixing up the tests)

]

operations = [
corehq.apps.es.migration_operations.UpdateIndexMapping(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh! Another thing, since we have created the new indices that we would using for ES 6 migration, you would need to add another UpdateIndexMapping block manually in operations array.

It would look something like


        corehq.apps.es.migration_operations.UpdateIndexMapping(
            name=index_runtime_name('forms-2024-05-09'),
            type_='xform',
            properties={
            ....
           }, 
           es_versions=[],
          )

forms-2024-05-09 is the name of new index. You can find the info here

@Charl1996
Copy link
Contributor Author

Closing in favour of #34824 (which have a better looking commit history)

@Charl1996 Charl1996 closed this Jun 26, 2024
@mkangia mkangia deleted the add-form-load-time-to-es branch June 26, 2024 10:58
@mkangia
Copy link
Contributor

mkangia commented Jun 26, 2024

Good call @Charl1996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants