Build JSON metadata for Documents at save

RESOLVED FIXED

Status

Mozilla Developer Network
Performance
P1
normal
RESOLVED FIXED
5 years ago
2 years ago

People

(Reporter: lorchard, Unassigned)

Tracking

Details

(Whiteboard: [specification][type:change])

(Reporter)

Description

5 years ago
* Refactor _get_document_for_json in views.py to a Document.to_json() method in models.py - https://github.com/mozilla/kuma/blob/master/apps/wiki/views.py#L283

* Add a blob/text field to the Document model, eg. json_meta

* When a Document is changed & saved, build the JSON representation with document.to_json() & stash that in json_meta.

* When a Document is fetched, check json_meta. If it's empty, build $json representation & update the doc.

* (optional) Write a script that sweeps through all documents and fills in json_meta. Run this after deployment of all the above.

Doing the above front-loads the work of building JSON metadata for docs (including tags, localizations, etc), and ties it to when content is changed. At retrieval time, all the hard work should have already been done.

Then, we can offer an option for page.subpages that expands Document metadata by simply including the contents of json_meta. That gets us tags & all the rest. This also should make page.getPage() run much faster.

I'll probably end up doing this, but hopefully the details above give a decent starting point if someone else wants to scoop this up.

Comment 1

5 years ago
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/b7a7f23a507ace8adb0a273562318b6d254c913e
bug 875349: Build JSON metadata for Documents at rendering time

https://github.com/mozilla/kuma/commit/b72f8b4428c2f09be20177662127587aceece3e3
Merge pull request #1138 from lmorchard/875349-document-json-on-save

bug 875349: Build JSON metadata for Documents at rendering time
Where are we on this? There were PRs, and I think this landed, but the bug is still open. What's up?
From what I can tell looking at the code this is done. Closing.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.