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

[Discussion] Implementing post updating and history #102

Open
emilyst opened this issue Apr 14, 2022 · 1 comment
Open

[Discussion] Implementing post updating and history #102

emilyst opened this issue Apr 14, 2022 · 1 comment

Comments

@emilyst
Copy link
Contributor

emilyst commented Apr 14, 2022

Opening this issue to memorialize a brief discussion we had in IRC about adding post updating.

Currently it's not possible to update a Post in place, and there's no concept of revisions that can be compared. Right now, there's a Post model and a File model. Posts have a one-to-many relationship with Files (each Post has one or more Files). My suggestion is that it should be possible to elaborate on this design slightly to add the ability to add updating and history.

First, update the File model:

  • Add a replaces nullable foreign key column.
  • Add a checksum nullable column of some sort to contain a checksum (maybe a BLAKE3 checksum, but it doesn't matter).
  • Add a diff column, as a nullable string.

Wherever we render the Files belonging to a Post, we would filter out any File referenced by another File as replaces. Whatever is left is the Post's current Files.

Updating a Post would mean presenting the contents of each File to edit. When the form is posted to update the Post's Files, it would be necessary to figure out which, if any, Files got their contents changed. You could use a checksum for determining this. For any File whose contents' checksum has changed:

  • Create a new File.
  • Associate that new File with the same Post.
  • Set the new File's replaces to the ID of the old File which it replaces.
  • Set the new File's contents in the contents column.
  • Diff the new File's contents against the old, and store that in the diff column.
  • Calculate the checksum of the new File's contents, and store that in the checksum column.

To show the history for a given Post, iterate over each of its current Files (any File not referenced by another File as replaces). Then for each File:

  • If the File's replaces column is null, skip and move on to the next File current for the Post.
  • If the File replaces another File, grab the replaced File's diff.
  • Repeat the first two steps with the replaced File.

You can just display those diffs somewhere for each File as its history.

Hopefully the above captures the idea well enough. Every bit of it is just an optional suggestion, so don't take any of it too literally.

@MaxLeiter
Copy link
Owner

@jazcarate I'm interested in your thoughts on this if you have time to give it a look and have anything to add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo / help welcome
Development

No branches or pull requests

2 participants