6.0.0-git
2019-03-19

[#12558] History: Add getLatestEntry($guid)
Summary History: Add getLatestEntry($guid)
Queue Horde Framework Packages
Queue Version Git master
Type Enhancement
State Resolved
Priority 1. Low
Owners mrubinsk (at) horde (dot) org
Requester thomas.jarosch (at) intra2net (dot) com
Created 2013-08-10 (2047 days ago)
Due
Updated 2013-08-22 (2035 days ago)
Assigned 2013-08-21 (2036 days ago)
Resolved 2013-08-22 (2035 days ago)
Milestone
Patch Yes

History
2013-08-22 03:58:04 Michael Rubinsky Comment #9
State ⇒ Resolved
Reply to this comment
Committed, thanks!
2013-08-22 03:57:40 Git Commit Comment #8 Reply to this comment
Changes have been made in Git (master):

commit e5df3a27d590dfe98ec936cfc6706784593c5399
Author: Thomas Jarosch <thomas.jarosch@intra2net.com>
Date:   Wed Aug 21 10:57:19 2013 +0200

     Add getLatestEntry($guid) to get the latest history entry for a 
given $guid

     The SQL version is very efficient since it does not need
     to loop through all history entries for the object
     to determine the latest entry.

     Request 12558

     Signed-off-by: Michael J Rubinsky <mrubinsk@horde.org>

  framework/History/lib/Horde/History.php     |   36 
+++++++++++++++++++++++++++
  framework/History/lib/Horde/History/Sql.php |   32 ++++++++++++++++++++++++
  2 files changed, 68 insertions(+), 0 deletions(-)

http://git.horde.org/horde-git/-/commit/e5df3a27d590dfe98ec936cfc6706784593c5399
2013-08-22 03:45:10 Michael Rubinsky Deleted Original Message
 
2013-08-21 09:13:46 Thomas Jarosch Comment #7
State ⇒ Assigned
New Attachment: v2-0001-Add-getLatestEntry-guid-to-get-the-latest-history-en.patch Download
Reply to this comment
I've updated the code with the optimized SQL statement using ORDER BY.

Also I've fixed a bug that only occurred during productive testing:
If db->selectOne() didn't find a row, it returned an array with
all the requested keys set and empty values. Could be related to the 
MAX() statement
and/or the explicit specification of the field names in the previous 
SQL statement.

Therefore I've adapted the code to check if $row['history_id'] is really set.
No unit test yet, productive testing has to do for now :o)

2013-08-17 02:04:33 Michael Rubinsky State ⇒ Feedback
 
2013-08-13 14:27:32 Michael Rubinsky Assigned to Michael Rubinsky
State ⇒ Accepted
 
2013-08-12 20:33:23 Thomas Jarosch Comment #6 Reply to this comment
sign of live
...we all love this moment in life when you spot
a typo and already pressed the submit button :)

2013-08-12 20:31:43 Thomas Jarosch Comment #5 Reply to this comment
You will need to add a GROUP BY clause if you are returning 
non-aggregate fields in the query along with an aggregate field 
(MAX). This will work in mySql, but not pgsql. That being said, can 
you just get rid of the MAX and use ORDER BY history_modseq DESC   
and add limit => 1 instead? See Bug: 12476
ok, can do.
Also, would be great if you could add a test as well :)
I knew you would say that :o)

I'll revisit this probably after my holidays (=October). The latest changes
to the Kolab Horde History already make use of it but as my
pull request doesn't see any sign of live, it's not a problem anyway :P

2013-08-12 19:28:56 Michael Rubinsky Comment #4 Reply to this comment
You will need to add a GROUP BY clause if you are returning 
non-aggregate fields in the query along with an aggregate field (MAX). 
This will work in mySql, but not pgsql. That being said, can you just 
get rid of the MAX and use ORDER BY history_modseq DESC  and add limit 
=> 1 instead? See Bug: 12476


Also, would be great if you could add a test as well :)


2013-08-12 19:19:26 Michael Rubinsky Deleted Original Message
 
2013-08-12 18:53:14 Thomas Jarosch Comment #3
New Attachment: 0001-Add-getLatestEntry-guid-to-get-the-latest-history-en.patch
Reply to this comment
Looks like you attached the wrong patch?
thanks, this is the right one :)

2013-08-12 18:23:43 Michael Rubinsky Comment #2
State ⇒ Feedback
Reply to this comment
Looks like you attached the wrong patch?
2013-08-10 15:42:00 Thomas Jarosch Comment #1
Type ⇒ Enhancement
State ⇒ New
Priority ⇒ 1. Low
Summary ⇒ History: Add getLatestEntry($guid)
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ Yes
New Attachment: 0001-Remove-empty-birthday-or-anniversary-fields-during-K.patch
Reply to this comment
Hi,

I needed a way to get the latest history entry for a given $guid.
Since I needed it in two places now, I thought it's a good
idea to have a generic implementation in Horde_History.

I've also written an efficient version for the SQL driver
and tested both. Please see the attached patch.

Cheers,
Thomas

Saved Queries