Skip to content

Conversation

@Agrendalath
Copy link
Member

@Agrendalath Agrendalath commented Mar 31, 2025

This replaces the identifiers of the Learning Paths. Instead of the UUIDs, they will be identified by LearningPathKeys.

Testing instructions

  1. Check that you can access your existing Learning Paths.
  2. Check that the APIs work correctly.

Private-ref: BB-9241

@Agrendalath Agrendalath self-assigned this Mar 31, 2025
@Agrendalath Agrendalath force-pushed the agrendalath/bb-9241-refactor-keys branch 6 times, most recently from 27ce2c3 to 41b19ce Compare March 31, 2025 20:12
@Agrendalath Agrendalath force-pushed the agrendalath/bb-9241-refactor-keys branch 2 times, most recently from f20c2ef to c6587b6 Compare April 1, 2025 13:59
LearningPath = apps.get_model("learning_paths", "LearningPath")

for learning_path in LearningPath.objects.all():
key_str = f"path-v1:test+test+test+{learning_path.uuid}"
Copy link
Member Author

Choose a reason for hiding this comment

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

This plugin has not been deployed anywhere yet, so this function will only affect dev environments.


__slots__ = KEY_FIELDS

_learing_path_key_regex = re.compile(rf"^{LEARNING_PATH_PATTERN}$")
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Missing n in learning.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pkulkark, fixed in 958a37a.

Copy link
Member

@pkulkark pkulkark left a comment

Choose a reason for hiding this comment

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

@Agrendalath The changes look good but when I try to run it on my machine, I get this error during migration:

Applying learning_paths.0007_replace_uuid_with_learningpathkey...Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry '' for key 'learning_paths_learningpath.key'")

@Agrendalath
Copy link
Member Author

Agrendalath commented Apr 2, 2025

@pkulkark, I fixed the migration in b8b80fd.
I also added an explanation in f703ced.

Copy link
Member

@pkulkark pkulkark left a comment

Choose a reason for hiding this comment

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

@Agrendalath LGTM 👍

  • I tested this: Verified existing APIs and learning paths are accessible with the new key.
  • I read through the code
  • Includes documentation N/A

@Agrendalath Agrendalath force-pushed the agrendalath/bb-9241-refactor-keys branch from bd3e216 to f9f2264 Compare April 3, 2025 11:19
@Agrendalath Agrendalath enabled auto-merge April 3, 2025 11:20
@Agrendalath Agrendalath merged commit acda6b2 into main Apr 3, 2025
6 checks passed
@Agrendalath Agrendalath deleted the agrendalath/bb-9241-refactor-keys branch April 3, 2025 11:20
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.

3 participants