Open cloudiirain opened 8 years ago
I'd do it so the Chapter
table is just a table with a single One-to-Many to many history objects ordered by timestamp.
That way, the chapter_history
table contains the actual data, and the current chapter revision can be got by looking up the first item of the relationship.
@SunDwarf, that's totally fine -- and do the same things with Series information, etc.?
@scraeling suggested that we store git diffs. I actually think it's easier to store the full body of the text with every revision and compute the diffs if we need them. Database size might be bigger this way, but I'm all for doing the easier thing. ;-;
Well, you have the tradeoff between CPU time and storage there. But the first one can effectively be avoided with a cache, or similar.
I think I'm going to just nest a page schema within the chapters schema for this.
schema.pageSchema=new mongoose.Schema({
timestamp:Date,
hash:String,
text:String,
user_id:Number
});
schema.chapterSchema=new mongoose.Schema({
title:String,
page:[schema.pageSchema],
linktype:String,
link:String
});
Looking for some advice on how to implement revision history.
User Story
A user/moderator clicks on a series page. They see that another user has spammed the page with nonsense (or information that is plain wrong). This needs to be reverted, so they click on the revision history and restore a previous version.
An editor just made a chapter to a chapter the translator is not happy about. Translator wants to revert the chapter text.
A moderator wants to view the Recent Changes of everything on the app in one place, in chronological order.
The dumb way of implementing revision history
The mongo way (at least, this is how I think people would do it in Mongo)
But honestly I don't really know how to best approach this
Any pointers? Advice?