6.0.0-alpha14
6/24/25

[#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 08/10/2013 (4336 days ago)
Due
Updated 08/22/2013 (4324 days ago)
Assigned 08/21/2013 (4325 days ago)
Resolved 08/22/2013 (4324 days ago)
Milestone
Patch Yes

History
08/22/2013 03:58:04 AM Michael Rubinsky Comment #9
State ⇒ Resolved
Reply to this comment
Committed, thanks!
08/22/2013 03:57:40 AM 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
08/22/2013 03:45:10 AM Michael Rubinsky Deleted Original Message
 
08/21/2013 09:13:46 AM Thomas Jarosch Comment #7
New Attachment: v2-0001-Add-getLatestEntry-guid-to-get-the-latest-history-en.patch Download
State ⇒ Assigned
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)

08/17/2013 02:04:33 AM Michael Rubinsky State ⇒ Feedback
 
08/13/2013 02:27:32 PM Michael Rubinsky Assigned to Michael Rubinsky
State ⇒ Accepted
 
08/12/2013 08:33:23 PM 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 :)

08/12/2013 08:31:43 PM 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

08/12/2013 07:28:56 PM 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 :)


08/12/2013 07:19:26 PM Michael Rubinsky Deleted Original Message
 
08/12/2013 06:53:14 PM 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 :)

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