Skip to content

Conversation

poju3185
Copy link
Contributor

Fix #4470

Summary

Description of the change(s) you made

Changes save_export_database function and its calling context within the create_content_database function. The goal is to include the channel version in the exported SQLite database filename.

Manual verification steps performed

  1. Open studio in broswer.
  2. Publish a new channel ( or update an existing channel).
  3. Go to ./.docker/minio/content/databases/ to see the exported sqlite3 file name.

Reviewer's Checklist

This section is for reviewers to fill out.

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@rtibbles rtibbles self-assigned this Mar 18, 2024
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Halfway there! Just need to implement both paths.

def save_export_database(channel_id, version):
logging.debug("Saving export database")
current_export_db_location = get_active_content_database()
target_export_db_location = os.path.join(settings.DB_ROOT, "{id}.sqlite3".format(id=channel_id))
Copy link
Member

Choose a reason for hiding this comment

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

Hi @poju3185 - just one thing to flag here, if you read the issue carefully, you will see that it is desirable to continue to export the channel database to the current location as well. The issue is asking to save the database to both the old path and the new path. This means we can keep an archive of the channel databases, but continue to have the 'latest' with the simple name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the adjustments based on the feedback, and now the database is being saved to both the old and new paths. Thanks for pointing this out!

Copy link
Member

Choose a reason for hiding this comment

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

Excellent, this looks like the right change now, I'll test it out!

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Just one more tweak needed that showed up in manual testing.

progress_tracker.track(90)
map_prerequisites(channel.main_tree)
save_export_database(channel.pk)
save_export_database(channel.pk, channel.version)
Copy link
Member

Choose a reason for hiding this comment

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

This works perfectly except for one thing - the channel version gets incremented after this function is called (look above to see where create_content_database and increment_channel_version are called respectively!)

So, here you need to instead pass in channel.version + 1 and add a code comment as to why we are incrementing it here.

Copy link
Member

Choose a reason for hiding this comment

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

You will see similar logic happening inside the map_channel_to_kolibri_channel function where the version written into the database is incremented by one also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the adjustments to pass in channel.version + 1 as suggested and added a comment in the code to explain why we're incrementing the version at this point. Thank you for pointing that out!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I'll test locally, and then hopefully this should be good to merge!

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Manual testing checks out, this is good to go! Thank you @poju3185

@rtibbles rtibbles merged commit 18e0bf1 into learningequality:unstable Mar 29, 2024
@akolson akolson mentioned this pull request Aug 13, 2024
@akolson akolson mentioned this pull request Oct 1, 2024
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.

Generate a versioned copy of the channel database when publishing
2 participants