2

I want to show the user the last 10 changes across all of my database objects.

I'm using django-reversion to track the history of changes to my model objects. I'm also somewhat duplicating this in a summary view. Where reversion creates a history list by object, the summary view just tracks a single list with each change in chronological order. Is it more efficient to query with this summary list, or could/should I simply query all of the reversion tables for the most recent 10 edits across all objects?

Second part: I want to show a user their edits grouped by object

So let's say a user edited 3 objects 10 times each. The user edited each object on different days, so on Day 1, the user edited all 3, on Day 2, the user edited maybe 1 of them, etc. I want to show the user a table that reads as follows

Object      Date of your most recent edit    Date of last edit  
Object 1            12-24-11                     12-25-11  
Object 2            12-20-11                     12-23-11  

Where the second column is the most recent user specific edit and the third column is the most recent edit by any user.

I want the user to be able to select Object 1, and then see all of their edits for that Object:

Object      Date of your most recent edit    Date of last edit
Object 1            12-24-11                     12-25-11
   edited name      12-24-11
   edited type      12-19-11
   edited subject   12-18-11
   edited date      12-18-11
   edited type      12-16-11
Object 2            12-20-11                     12-23-11

How might I structure this query? The most direct way I can think of is to query the distinct/unique list of objects filtered by user from either the reversion tables or the summary table, then query reversion by user and by object to get the more detailed history. This seems like it could be more efficient.

Might I want to create another summary table by user that would track the changes for easier querying in this format? How would I structure that type of table?

Some code. I use this to get a list of all the history for a given object. It gives me the list of versions for a database object, a note about what was edited, the date of edit, and the user that made the change:

version_list = Version.objects.get_for_object(object).select_related("revision__user")

And I simply use this to get a simple list of edits. In this summary table, the last 10 entries are the most recent changes (object, details on what was changed, date, and user):

whats_new_items = WhatsNew.objects.all()[0:10]
Ed.
  • 4,439
  • 10
  • 60
  • 78

0 Answers0