I think everyone would agree we want a field to indicate when a user-created node was last updated, but the details are a little fuzzy.

What kinds of updates do we want to end up setting this field?

Obviously user edits to the doctext (for types including document). IMO changes to the title should also set it, as should changes to fields of non-document types (e.g. snippets). I'd also want Q&AEditor/SDC/janitor/pedagogue changes to set it. I don't care one way or the other whether hitting "Update" without having changed anything updates it. The field should probably be set the same as createtime at node creation (currently, lastedit often varies from createtime by one or more seconds because node and document are updated separately), not zero. Any other updates should IMO not set the field.

Implementation notes (some of which depend on things I say above that others may disagree with):

Having the lastedit field in document doesn't work for non-document types, or for having it match createtime, so it should move to node. I'd make it a datetime field, instead of a timestamp, since we don't want the magic autoupdate behaviour that timestamps have (though I think that only happens with the first timestamp field in the table). Also note that apparently timestamps are changed to return by default as strings as of MySQL 4.1. When the new node.lastedit field is added, it should be set the same as createtime.

Then the following changes should be enough:
Everything/NodeBase.pm (insertNode): add -lastedit => "now()"
Everything/HTML.pm (gotoNode) and handle_node_edits: fetch now() and set $NODE->{lastedit} to it before calling updateNode

  • Comment on maintaining a time of last edit for nodes

Replies are listed 'Best First'.
Re: maintaining a time of last edit for nodes
by jdporter (Paladin) on Jan 05, 2007 at 07:27 UTC

    I think, for now, we should simply set (update) document.lastedit when document.doctext is modified via a high-level edit operation. Clearly, updating lastedit whenever the document record is written back to the DB is bad (or at least useless).

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
Re: maintaining a time of last edit for nodes
by ysth (Canon) on Feb 13, 2006 at 09:49 UTC
    I'm going to assume silence eq "no criticism" and start implementing this in a couple of days.

      The only thing I was going to say is that i think there is utility in having a lastedit stamp associated to document types and a seperate stamp for non documents.

      Id also like to see it possible to index the node specific last edit, so I'd prefer it wasnt updated if only the document table was being modified.

      Sorry for lagging on my reply.

      ---
      $world=~s/war/peace/g

      O.k., time's up! Did you do this? ;-)

      We're building the house of the future together.
        I didn't say which couple of days :)