Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Decode plot data from bytestring to utf-8 before storing in database #14

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

backmari
Copy link
Collaborator

@backmari backmari commented Jun 7, 2024

Short description of the changes:

When storing plot data from a request to Live Data Server, we need to decode the plot data from bytestring to UTF-8 first.

Long description of the changes:

After deploying the latest version of Live Data Server, new plots that are published to Live Data Server appear on monitor.sns.gov with '\n' instead of linebreaks:

Screenshot from 2024-06-04 10-34-24

This seems related to a Django 2.0 change in how bytestrings are handled: https://docs.djangoproject.com/en/5.0/releases/2.0/#removed-support-for-bytestrings-in-some-places

Check list for the pull request

  • I have read the [CONTRIBUTING]
  • I have read the [CODE_OF_CONDUCT]
  • I have added tests for my changes
  • I have updated the documentation accordingly

Check list for the reviewer

  • I have read the [CONTRIBUTING]
  • I have verified the proposed changes
  • best software practices
    • all internal functions have an underbar, as is python standard
    • clearly named variables (better to be verbose in variable names)
    • code comments explaining the intent of code blocks
  • All the tests are passing
  • The documentation is up to date
  • code comments added when explaining intent

Manual test for the reviewer

Define environment variables (set the hidden values to any strings you like):

export DATABASE_NAME=***
export DATABASE_USER=***
export DATABASE_PASS=***
export DATABASE_HOST=db  # name of the db docker service
export DATABASE_PORT=5432
export LIVE_PLOT_SECRET_KEY=***
export DJANGO_SUPERUSER_USERNAME=$DATABASE_USER
export DJANGO_SUPERUSER_PASSWORD=$DATABASE_PASS

Start the containers:

make local/docker/up

and when the containers are up run the unit test:

pytest tests

References

Defect 5534: Live Data Server plot html string encoding issue

Copy link
Member

@jmborr jmborr left a comment

Choose a reason for hiding this comment

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

looks 👌

@backmari backmari merged commit 05627f9 into main Jun 10, 2024
@backmari backmari deleted the encoding_defect branch June 10, 2024 11:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants