WeebWare / Ranobe-Honyaku

A novel translation platform.
MIT License
8 stars 2 forks source link

Revision History (Modeling) #8

Open cloudiirain opened 8 years ago

cloudiirain commented 8 years ago

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

Any pointers? Advice?

cloudiirain commented 8 years ago

Update: Can confirm that postgresql can store json.

Fuyukai commented 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.

cloudiirain commented 8 years ago

@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. ;-;

Fuyukai commented 8 years ago

Well, you have the tradeoff between CPU time and storage there. But the first one can effectively be avoided with a cache, or similar.

danieltanfh95 commented 8 years ago

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
});