View Issue Details

IDProjectCategoryView StatusLast Update
0010539mantisbtfilterspublic2015-10-21 15:39
Reportergthomas Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status confirmedResolutionopen 
PlatformLinuxOSUbuntuOS Version9.04
Product Version1.3.0-beta.1 
Summary0010539: Last updater
Description

I need the last updater (the person who last added a note) at least on the my_view_page.

This gets the data from filter_bug_get_rows function, so I added a not-too optimized SQL clause to produce the needed data.

Tagspatch

Relationships

related to 0019476 closedvboctor show added note on resolve to excel_columns 

Activities

2009-05-26 15:18

 

last_updater.git.patch (2,111 bytes)   
From 905abc91fb63261f92b070298e19e5d3416d1a52 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Gul=C3=A1csi=20Tam=C3=A1s?= <gthomas@hackworth.guba>
Date: Tue, 26 May 2009 21:05:15 +0200
Subject: [PATCH] let filter_get_bug_rows return the last updater, too


diff --git a/core/filter_api.php b/core/filter_api.php
index 5aa5bbb..88ab3ce 100644
--- a/core/filter_api.php
+++ b/core/filter_api.php
@@ -1851,6 +1851,20 @@ function filter_get_bug_rows( &$p_page_number, &$p_per_page, &$p_page_count, &$p
 	if( 0 == $p_bug_count ) {
 		return array();
 	}
+
+    # GT:
+    $t_user_table = config_get('mantis_user_table');
+    $t_select_clauses[] =
+        "(SELECT COALESCE(MAX(D.username), '') last_submitter
+            FROM $t_user_table D, $t_bugnote_table C
+		    WHERE D.id = C.reporter_id AND
+		          C.id = (SELECT MAX(B.id)
+			                FROM $t_bugnote_table B
+			                WHERE B.bug_id = $t_bug_table.id)
+		  ) last_submitter";
+    $t_query_clauses['select'] = $t_select_clauses;
+    # :GT
+
 	$p_per_page = filter_per_page( $t_filter, $p_bug_count, $p_per_page );
 	$p_page_count = filter_page_count( $p_bug_count, $p_per_page );
 	$p_page_number = filter_valid_page_number( $p_page_number, $p_page_count );
@@ -3703,7 +3717,7 @@ function print_filter_note_user_id() {
 					check_selected( $t_filter[FILTER_PROPERTY_NOTE_USER_ID], META_FILTER_MYSELF );
 					echo '>[' . lang_get( 'myself' ) . ']</option>';
 				}
-		
+
 				print_assign_to_option_list( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] );
 			}
 		?>
diff --git a/core/my_view_inc.php b/core/my_view_inc.php
index a4b8020..d4232fc 100644
--- a/core/my_view_inc.php
+++ b/core/my_view_inc.php
@@ -512,9 +512,9 @@ echo "($v_start - $v_end / $t_bug_count)";
 	}
 
 	if( $v_last_updated > strtotime( '-' . $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] . ' hours' ) ) {
-		echo ' - <b>' . $t_last_updated . '</b>';
+		echo ' - <b>' . $t_last_updated . ' - {' . $v_last_updater . '}</b>';
 	} else {
-		echo ' - ' . $t_last_updated;
+		echo ' - ' . $t_last_updated . ' - {' . $v_last_updater . '}';
 	}
 	?>
 		</span>
-- 
1.6.0.4

last_updater.git.patch (2,111 bytes)   
gthomas

gthomas

2009-09-26 00:17

reporter  

last_reporter-1.2.0rc2.patch (2,312 bytes)   
diff -r 04bb28dd6964 core/bug_api.php
--- a/core/bug_api.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/core/bug_api.php	Sat Sep 26 06:15:09 2009 +0200
@@ -1309,6 +1309,34 @@
 }
 
 /**
+ * return the reporter (user_id) for the most recent time at which a bugnote
+ *  associated with the bug was modified
+ * @param int p_bug_id integer representing bug id
+ * @return bool|int false or user id in integer format representing newest bugnote reporter
+ * @access public
+ * @uses database_api.php
+ */
+function bug_get_newest_bugnote_reporter( $p_bug_id ) {
+	$c_bug_id = db_prepare_int( $p_bug_id );
+	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
+
+	$query = "SELECT MIN(reporter_id)
+				  FROM $t_bugnote_table A
+				  WHERE A.date_submitted = (SELECT MIN(X.date_submitted)
+				                               FROM $t_bugnote_table X
+				                               WHERE X.id = A.id) AND
+				        A.bug_id=" . db_param(); 
+	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
+	$row = db_result( $result );
+
+	if( false === $row ) {
+		return false;
+	} else {
+		return $row;
+	}
+}
+
+/**
  * return the timestamp for the most recent time at which a bugnote
  *  associated with the bug was modified and the total bugnote
  *  count in one db query
diff -r 04bb28dd6964 my_view_inc.php
--- a/my_view_inc.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/my_view_inc.php	Sat Sep 26 06:15:09 2009 +0200
@@ -442,6 +442,9 @@
 	$t_summary = string_display_line_links( $t_bug->summary );
 	$t_last_updated = date( config_get( 'normal_date_format' ), $t_bug->last_updated );
 
+	$t_last_reporter_id = bug_get_newest_bugnote_reporter( $t_bug->id );
+	$t_last_reporter = $t_last_reporter_id ? user_get_name( $t_last_reporter_id ) : '';
+
 	# choose color based on status
 	$status_color = get_status_color( $t_bug->status );
 
@@ -506,9 +509,9 @@
 	echo string_display_line( category_full_name( $t_bug->category_id, true, $t_bug->project_id ) );
 
 	if( $t_bug->last_updated > strtotime( '-' . $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] . ' hours' ) ) {
-		echo ' - <b>' . $t_last_updated . '</b>';
+		echo ' - <b>' . $t_last_updated . ' - ' . $t_last_reporter . '</b>';
 	} else {
-		echo ' - ' . $t_last_updated;
+		echo ' - ' . $t_last_updated . ' - ' . $t_last_reporter;
 	}
 	?>
 		</span>
last_reporter-1.2.0rc2.patch (2,312 bytes)   
gthomas

gthomas

2009-09-26 00:22

reporter   ~0023034

The "last_reporter-1.2.0rc2.patch" is against the daily snapshot at 2009-09-21.

It contains the addition of the bug_get_newest_bugnote_reporter function, which returns the latest bug reporter's user id, and a usage example of it in my_view_inc.php

Hope this is useful!

gthomas

gthomas

2009-09-28 15:32

reporter  

last_reporter-1.2.0rc2-v2.patch (2,315 bytes)   
diff -r 04bb28dd6964 core/bug_api.php
--- a/core/bug_api.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/core/bug_api.php	Sat Sep 26 06:15:09 2009 +0200
@@ -1309,6 +1309,34 @@
 }

 /**
+ * return the reporter (user_id) for the most recent time at which a bugnote
+ *  associated with the bug was modified
+ * @param int p_bug_id integer representing bug id
+ * @return bool|int false or user id in integer format representing newest bugnote reporter
+ * @access public
+ * @uses database_api.php
+ */
+function bug_get_newest_bugnote_reporter( $p_bug_id ) {
+	$c_bug_id = db_prepare_int( $p_bug_id );
+	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
+
+	$query = "SELECT MIN(reporter_id)
+				  FROM $t_bugnote_table A
+				  WHERE A.date_submitted = (SELECT MIN(X.date_submitted)
+				                               FROM $t_bugnote_table X
+				                               WHERE X.bug_id = A.bug_id) AND
+				        A.bug_id=" . db_param();
+	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
+	$row = db_result( $result );
+
+	if( false === $row ) {
+		return false;
+	} else {
+		return $row;
+	}
+}
+
+/**
  * return the timestamp for the most recent time at which a bugnote
  *  associated with the bug was modified and the total bugnote
  *  count in one db query
diff -r 04bb28dd6964 my_view_inc.php
--- a/my_view_inc.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/my_view_inc.php	Sat Sep 26 06:15:09 2009 +0200
@@ -442,6 +442,9 @@
 	$t_summary = string_display_line_links( $t_bug->summary );
 	$t_last_updated = date( config_get( 'normal_date_format' ), $t_bug->last_updated );

+	$t_last_reporter_id = bug_get_newest_bugnote_reporter( $t_bug->id );
+	$t_last_reporter = $t_last_reporter_id ? user_get_name( $t_last_reporter_id ) : '';
+
 	# choose color based on status
 	$status_color = get_status_color( $t_bug->status );

@@ -506,9 +509,9 @@
 	echo string_display_line( category_full_name( $t_bug->category_id, true, $t_bug->project_id ) );

 	if( $t_bug->last_updated > strtotime( '-' . $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] . ' hours' ) ) {
-		echo ' - <b>' . $t_last_updated . '</b>';
+		echo ' - <b>' . $t_last_updated . ' - ' . $t_last_reporter . '</b>';
 	} else {
-		echo ' - ' . $t_last_updated;
+		echo ' - ' . $t_last_updated . ' - ' . $t_last_reporter;
 	}
 	?>
 		</span>
gthomas

gthomas

2009-09-28 15:32

reporter   ~0023040

Corrected a typo (X.id = A.id -> X.bug_id = A.bug_id)

dhx

dhx

2009-10-04 20:25

reporter   ~0023054

Thanks for your patches! I have a few comments/concerns however.

  1. You should add a new column to columns_api rather than extend the functionality of an existing one. The last update date and last update author are completely different things and as such should both be treated independently. Some users may want to know the last update date, but doesn't necessarily need to know who made the update.

See http://git.mantisbt.org/?p=mantisbt.git;a=commitdiff;h=6e5852da462e8a6e01e3f2e9ce329d50e88dfbf2 for an example of how to add a new column. Note that that patch doesn't handle columns in the CSV output (which is bad... it's on my TODO list).

2.

  • if( false === $row ) {
  • return false;
  • } else {
  • return $row;
  • }

This is a useless check. "return $row" does the same thing.

  1. I think it's a bit misleading to use the word "updated" and yet ignore other forms of update (changing the priority, etc). I think it'd be better to check the last user_id for the history of a given bug so it truly does represent the last updater.

  2. Can you please justify your usage of the SQL "COALESCE" function? It doesn't look right to me. Is it supported by AdoDB for the common databases (MySQL, PostgreSQL, MSSQL, Oracle, SQLite etc)? I thought that the SQL standard required databases to return a value of NULL from MAX(column) where "column" is from a table with no matching rows. In which case, can't we just check (with PHP) that the result is NULL or an integer?

gthomas

gthomas

2009-10-12 04:51

reporter  

last_reporter-1.2.0rc2-v3.patch (6,273 bytes)   
diff -r 04bb28dd6964 core/bug_api.php
--- a/core/bug_api.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/core/bug_api.php	Mon Oct 12 10:49:02 2009 +0200
@@ -1286,11 +1286,11 @@
  * return the timestamp for the most recent time at which a bugnote
  *  associated with the bug was modified
  * @param int p_bug_id integer representing bug id
- * @return bool|int false or timestamp in integer format representing newest bugnote timestamp
+ * @return bool|int false or timestamp in integer format representing last bugnote timestamp
  * @access public
  * @uses database_api.php
  */
-function bug_get_newest_bugnote_timestamp( $p_bug_id ) {
+function bug_get_last_bugnote_timestamp( $p_bug_id ) {
 	$c_bug_id = db_prepare_int( $p_bug_id );
 	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
 
@@ -1299,13 +1299,29 @@
 				  WHERE bug_id=" . db_param() . "
 				  ORDER BY last_modified DESC";
 	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
-	$row = db_result( $result );
+	return db_result( $result );
+}
 
-	if( false === $row ) {
-		return false;
-	} else {
-		return $row;
-	}
+/**
+ * return the reporter (user_id) for the most recent time at which a bugnote
+ *  associated with the bug was modified
+ * @param int p_bug_id integer representing bug id
+ * @return bool|int false or user id in integer format representing last bugnote reporter
+ * @access public
+ * @uses database_api.php
+ */
+function bug_get_last_bugnote_reporter( $p_bug_id ) {
+	$c_bug_id = db_prepare_int( $p_bug_id );
+	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
+
+	$query = "SELECT MIN(reporter_id)
+				  FROM $t_bugnote_table A
+				  WHERE A.date_submitted = (SELECT MAX(X.date_submitted)
+				                               FROM $t_bugnote_table X
+				                               WHERE X.bug_id = A.bug_id) AND
+				        A.bug_id=" . db_param(); 
+	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
+	return db_result( $result );
 }
 
 /**
diff -r 04bb28dd6964 core/columns_api.php
--- a/core/columns_api.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/core/columns_api.php	Mon Oct 12 10:49:02 2009 +0200
@@ -74,6 +74,8 @@
 
 	$t_columns['selection'] = null;
 	$t_columns['edit'] = null;
+	$t_columns['last_bugnote_reporter'] = null;
+	$t_columns['last_bugnote_timestamp'] = null;
 
 	if( OFF == config_get( 'enable_profiles' ) ) {
 		unset( $t_columns['os'] );
@@ -92,6 +94,13 @@
 	if( config_get( 'enable_product_build' ) == OFF ) {
 		unset( $t_columns['build'] );
 	}
+	
+	if( config_get( 'enable_last_bugnote_reporter', ON) == OFF ) {
+		unset( $t_columns['last_bugnote_reporter'] );
+	}
+	if( config_get( 'enable_last_bugnote_timestamp', OFF) == OFF ) {
+		unset( $t_columns['last_bugnote_timestamp'] );
+	}
 
 	# The following fields are used internally and don't make sense as columns
 	unset( $t_columns['_stats'] );
@@ -802,6 +811,34 @@
 
 /**
  *
+ * @param string sort
+ * @param string direction
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_title_last_bugnote_reporter( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	echo lang_get( 'last_bugnote_reporter' );
+	echo '</td>';
+}
+
+/**
+ *
+ * @param string sort
+ * @param string direction
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_title_last_bugnote_timestamp( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	echo lang_get( 'last_bugnote_timestamp' );
+	echo '</td>';
+}
+
+/**
+ *
  * @param BugData $p_bug bug obect
  * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
  * @return null
@@ -1271,3 +1308,41 @@
 
 	echo '</td>';
 }
+
+/**
+ *
+ * @param BugData $p_bug bug obect
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_last_bugnote_reporter( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	
+	$t_reporter_id = bug_get_last_bugnote_reporter( $p_bug->id );
+	
+	if( $t_reporter_id > 0 ) {
+		echo prepare_user_name( $t_reporter_id );
+	}
+
+	echo '</td>';
+}
+
+/**
+ *
+ * @param BugData $p_bug bug obect
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_last_bugnote_timestamp( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	
+	$t_timestamp = bug_get_last_bugnote_timestamp( $p_bug->id );
+	
+	if( $t_timestamp != null && $t_timestamp > 0 ) {
+		echo date( config_get( 'short_date_format' ), $t_timestamp );
+	}
+
+	echo '</td>';
+}
diff -r 04bb28dd6964 core/file_api.php
--- a/core/file_api.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/core/file_api.php	Mon Oct 12 10:49:02 2009 +0200
@@ -650,6 +650,11 @@
 	$c_bug_id = db_prepare_int( $p_bug_id );
 	$c_project_id = db_prepare_int( $t_project_id );
 	$c_file_type = db_prepare_string( $p_file['type'] );
+	# GT:
+	if( $c_file_type == 'image/pjpeg') {
+		$c_file_type = 'image/jpeg';
+	}
+	# :GT
 	$c_title = db_prepare_string( $p_title );
 	$c_desc = db_prepare_string( $p_desc );
 
diff -r 04bb28dd6964 my_view_inc.php
--- a/my_view_inc.php	Fri Sep 25 20:11:21 2009 +0200
+++ b/my_view_inc.php	Mon Oct 12 10:49:02 2009 +0200
@@ -442,6 +442,9 @@
 	$t_summary = string_display_line_links( $t_bug->summary );
 	$t_last_updated = date( config_get( 'normal_date_format' ), $t_bug->last_updated );
 
+	$t_last_reporter_id = bug_get_last_bugnote_reporter( $t_bug->id );
+	$t_last_reporter = $t_last_reporter_id ? user_get_name( $t_last_reporter_id ) : '';
+
 	# choose color based on status
 	$status_color = get_status_color( $t_bug->status );
 
@@ -506,9 +509,9 @@
 	echo string_display_line( category_full_name( $t_bug->category_id, true, $t_bug->project_id ) );
 
 	if( $t_bug->last_updated > strtotime( '-' . $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] . ' hours' ) ) {
-		echo ' - <b>' . $t_last_updated . '</b>';
+		echo ' - <b>' . $t_last_updated . ' - ' . $t_last_reporter . '</b>';
 	} else {
-		echo ' - ' . $t_last_updated;
+		echo ' - ' . $t_last_updated . ' - ' . $t_last_reporter;
 	}
 	?>
 		</span>
gthomas

gthomas

2009-10-12 04:54

reporter   ~0023150

Hi dhx,

  1. Added the "last_bugnote_reporter" and "last_bugnote_timestamp" columns to core/columns_api.php, but I see no use of them yet (I only need the "last_bugnote_reporter" on the "My View" page).

  2. fixed - seen it somewhere in that file, before.

  3. renamed to "last_bugnote_reporter" and "last_bugnote_timestamp".

  4. COALESCE is in the SQL92 standard, but of course not every engine has it (with this name, at least). ADOdb provides an IfNull semi-equivalent (http://phplens.com/lens/adodb/tips_portable_sql.htm#native), but anyway I left it out.

GThomas

dhx

dhx

2009-10-26 09:02

reporter   ~0023346

Apologies for my delayed response. Thanks for your feedback on my comments. I'll have another look at it soon and if it all looks good, I'll commit it for the upcoming 1.3.x release of Mantis.

Thanks!

dhx

dhx

2009-10-27 07:01

reporter  

issue10539_v1.diff (5,377 bytes)   
diff --git a/core/bug_api.php b/core/bug_api.php
index c0b6237..a24f03f 100644
--- a/core/bug_api.php
+++ b/core/bug_api.php
@@ -1298,29 +1298,42 @@ function bug_format_summary( $p_bug_id, $p_context ) {
 }
 
 /**
- * return the timestamp for the most recent time at which a bugnote
- *  associated with the bug was modified
+ * Return the timestamp of the most recent bugnote attached to a bug.
  * @param int p_bug_id integer representing bug id
- * @return bool|int false or timestamp in integer format representing newest bugnote timestamp
+ * @return bool|int false or timestamp in integer format representing last bugnote timestamp
  * @access public
  * @uses database_api.php
  */
-function bug_get_newest_bugnote_timestamp( $p_bug_id ) {
+function bug_get_last_bugnote_timestamp( $p_bug_id ) {
 	$c_bug_id = db_prepare_int( $p_bug_id );
 	$t_bugnote_table = db_get_table( 'bugnote' );
 
 	$query = "SELECT last_modified
-				  FROM $t_bugnote_table
-				  WHERE bug_id=" . db_param() . "
-				  ORDER BY last_modified DESC";
+	          FROM $t_bugnote_table
+	          WHERE bug_id=" . db_param() . "
+	          ORDER BY last_modified DESC";
 	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
-	$row = db_result( $result );
+	return db_result( $result );
+}
 
-	if( false === $row ) {
-		return false;
-	} else {
-		return $row;
-	}
+/**
+ * Return the user ID of the author/editor of the most recent bugnote
+ * attached to or modified within a bug.
+ * @param int p_bug_id integer representing bug id
+ * @return bool|int false or user id in integer format representing last bugnote reporter
+ * @access public
+ * @uses database_api.php
+ */
+function bug_get_last_bugnote_reporter( $p_bug_id ) {
+	$c_bug_id = db_prepare_int( $p_bug_id );
+	$t_bugnote_table = db_get_table( 'bugnote' );
+
+	$query = "SELECT reporter_id
+	          FROM $t_bugnote_table
+	          WHERE bug_id=" . db_param() . "
+	          ORDER BY last_modified DESC";
+	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
+	return db_result( $result );
 }
 
 /**
diff --git a/core/columns_api.php b/core/columns_api.php
index 76df895..d2ae256 100644
--- a/core/columns_api.php
+++ b/core/columns_api.php
@@ -74,6 +74,8 @@ function columns_get_standard() {
 
 	$t_columns['selection'] = null;
 	$t_columns['edit'] = null;
+	$t_columns['last_bugnote_reporter'] = null;
+	$t_columns['last_bugnote_timestamp'] = null;
 
 	# Overdue icon column (icons appears if an issue is beyond due_date)
 	$t_columns['overdue'] = null;
@@ -87,11 +89,11 @@ function columns_get_standard() {
 	if( config_get( 'enable_eta' ) == OFF ) {
 		unset( $t_columns['eta'] );
 	}
-	
+
 	if( config_get( 'enable_projection' ) == OFF ) { 
 		unset( $t_columns['projection'] );
 	}
-	
+
 	if( config_get( 'enable_product_build' ) == OFF ) {
 		unset( $t_columns['build'] );
 	}
@@ -814,6 +816,34 @@ function print_column_title_overdue( $p_sort, $p_dir, $p_columns_target = COLUMN
 }
 
 /**
+ * @DELETEME
+ * @param string sort
+ * @param string direction
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_title_last_bugnote_reporter( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	echo lang_get( 'last_bugnote_reporter' );
+	echo '</td>';
+}
+
+/**
+ * @DELETEME
+ * @param string sort
+ * @param string direction
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_title_last_bugnote_timestamp( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+	echo lang_get( 'last_bugnote_timestamp' );
+	echo '</td>';
+}
+
+/**
  *
  * @param BugData $p_bug bug obect
  * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
@@ -1328,3 +1358,41 @@ function print_column_overdue( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_P
 
 	echo '</td>';
 }
+
+/**
+ *
+ * @param BugData $p_bug bug obect
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_last_bugnote_reporter( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+
+	$t_reporter_id = bug_get_last_bugnote_reporter( $p_bug->id );
+
+	if ( $t_reporter_id > 0 ) {
+		echo prepare_user_name( $t_reporter_id );
+	}
+
+	echo '</td>';
+}
+
+/**
+ *
+ * @param BugData $p_bug bug obect
+ * @param int $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
+ * @return null
+ * @access public
+ */
+function print_column_last_bugnote_timestamp( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
+	echo '<td>';
+
+	$t_timestamp = bug_get_last_bugnote_timestamp( $p_bug->id );
+
+	if ( $t_timestamp !== false && $t_timestamp > 0 ) {
+		echo date( config_get( 'short_date_format' ), $t_timestamp );
+	}
+
+	echo '</td>';
+}
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index 21829be..6687e0a 100644
--- a/lang/strings_english.txt
+++ b/lang/strings_english.txt
@@ -1193,6 +1193,8 @@ $s_issue_id = 'Issue #';
 $s_recently_visited = 'Recently Visited';
 $s_priority_abbreviation = 'P';
 $s_note_user_id = 'Note By';
+$s_last_bugnote_reporter = 'Last Bugnote Updated By';
+$s_last_bugnote_timestamp = 'Last Bugnote Timestamp';
 
 # view_all_inc.php
 $s_none = 'none';
issue10539_v1.diff (5,377 bytes)   
dhx

dhx

2009-10-27 07:21

reporter   ~0023402

I've reviewed your patch and have made a number of changes/corrections. Attached in issue10539_v1.diff is the results of my work.

I had to make the following changes:

1) The SQL query in bug_get_last_bugnote_reporter is ugly. In general, when you see nested SQL queries - it's a good sign the query is bad and can be replaced with a much simpler alternative. In this case, we can just use the ORDER BY statement and remove all the complex stuff you had in your original query.

2) I've removed the enable_lastbugnote* options as I couldn't justify why administrators would want to prevent users from viewing those columns if they wanted to do so. I agree that this functionality could be useful and I'd be happy to add it if it can be applied to all columns (including those added by plugins, custom fields, etc) consistently.

3) The strings used in print_column_title_lastbugnote* were not added to lang/strings_english.txt - I've added them to my patch.

4) In print_column_last_bugnote_timestamp we should be comparing the result of bug_get_last_bugnote_timestamp with "false" rather than "null" - and the check should be !== instead of != to ensure that types are preserved in the check.

5) Adding the last bugnote reporter to the data shown in my_view_inc.php doesn't seem right to me. We're displaying the timestamp that the bug was last updated so I'd expect to see the name of the user who last edited the bug. The bug last modification time that is shown also factors in the bugnotes too. I've removed this data for now, but would be happy to add it back later if this matter is fixed.

6) Your patch had what appeared to be some remnants of other work in file_api.php so I've removed that. Seems it got into your patch by accident :)

Before merging into 1.3.x I'd still like these points addressed:

1) The last bugnote updater and timestamp columns should be sortable (ascending or descending order) like all other similar columns.

2) I'd like to see a new column listing the user that last modified the bug (including bugnotes in this check) so that we maintain consistency. We'd thus have a column for the timestamp of the last modification to a bug (and any child bugnotes) and the user who performed the modification. And we'd also have a column listing the timestamp of the last modification or addition to bugnotes attached to a bug. Of course, this column would also have the last bugnote reporter or editor listed as well.

Let me know what you think about these comments I've made :)

gthomas

gthomas

2009-10-27 15:28

reporter   ~0023417

Thanks for correcting those ugliness!

About the points:
1) how do you make a column sortable? (example or point to start from will help)
2) multi-value columns? or make that much (last updater user + last modification timestamp + bugnote last modification timestamp)?

GT

gthomas

gthomas

2009-12-30 07:24

reporter  

last_updater.patch (2,963 bytes)   
diff --git a/core/bug_api.php b/core/bug_api.php
index c0b6237..dbd8b71 100644
--- a/core/bug_api.php
+++ b/core/bug_api.php
@@ -186,11 +186,11 @@ class BugData {
 			$this->fetch_extended_info();
 		return $this->{$name};
 	}
-	
+
 	/**
 	 * @private
 	 */
-	public function __isset($name) {	
+	public function __isset($name) {
 		return isset( $this->{$name} );
 	}
 
@@ -206,13 +206,13 @@ class BugData {
 		}
 		$this->loading = false;
 	}
-	
+
 	/**
 	 * Retrieves extended information for bug (e.g. bug description)
 	 * @return null
 	 */
 	private function fetch_extended_info() {
-		if ( $this->description == '' ) {				
+		if ( $this->description == '' ) {
 			$t_text = bug_text_cache_row($this->id);
 
 			$this->description = $t_text['description'];
@@ -1324,6 +1324,28 @@ function bug_get_newest_bugnote_timestamp( $p_bug_id ) {
 }
 
 /**
+ * return the reporter (user_id) for the most recent time at which a bugnote
+ *  associated with the bug was modified
+ * @param int p_bug_id integer representing bug id
+ * @return bool|int false or user id in integer format representing last bugnote reporter
+ * @access public
+ * @uses database_api.php
+ */
+function bug_get_last_bugnote_reporter( $p_bug_id ) {
+	$c_bug_id = db_prepare_int( $p_bug_id );
+	$t_bugnote_table = db_get_table( 'bugnote' );
+
+	$query = "SELECT MIN(reporter_id)
+				  FROM $t_bugnote_table A
+				  WHERE A.date_submitted = (SELECT MAX(X.date_submitted)
+				                               FROM $t_bugnote_table X
+				                               WHERE X.bug_id = A.bug_id) AND
+				        A.bug_id=" . db_param();
+	$result = db_query_bound( $query, Array( $c_bug_id ), 1 );
+	return db_result( $result );
+}
+
+/**
  * return the timestamp for the most recent time at which a bugnote
  *  associated with the bug was modified and the total bugnote
  *  count in one db query
diff --git a/my_view_inc.php b/my_view_inc.php
index c470b48..2230c3b 100644
--- a/my_view_inc.php
+++ b/my_view_inc.php
@@ -434,6 +434,9 @@ echo "($v_start - $v_end / $t_bug_count)";
 	$t_summary = string_display_line_links( $t_bug->summary );
 	$t_last_updated = date( config_get( 'normal_date_format' ), $t_bug->last_updated );
 
+	$t_last_reporter_id = bug_get_last_bugnote_reporter( $t_bug->id );
+	$t_last_reporter = $t_last_reporter_id ? user_get_name( $t_last_reporter_id ) : '';
+
 	# choose color based on status
 	$status_color = get_status_color( $t_bug->status );
 
@@ -498,9 +501,9 @@ echo "($v_start - $v_end / $t_bug_count)";
 	echo string_display_line( category_full_name( $t_bug->category_id, true, $t_bug->project_id ) );
 
 	if( $t_bug->last_updated > strtotime( '-' . $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] . ' hours' ) ) {
-		echo ' - <b>' . $t_last_updated . '</b>';
+		echo ' - <b>' . $t_last_updated . ' - ' . $t_last_reporter . '</b>';
 	} else {
-		echo ' - ' . $t_last_updated;
+		echo ' - ' . $t_last_updated . ' - ' . $t_last_reporter;
 	}
 	?>
 		</span>
last_updater.patch (2,963 bytes)   
atrol

atrol

2013-04-27 18:52

developer   ~0036718

Removed assignment. dhx will not contribute to this issue in near future.

Issue History

Date Modified Username Field Change
2009-05-26 15:18 gthomas New Issue
2009-05-26 15:18 gthomas File Added: last_updater.git.patch
2009-09-26 00:17 gthomas File Added: last_reporter-1.2.0rc2.patch
2009-09-26 00:22 gthomas Note Added: 0023034
2009-09-28 15:32 gthomas File Added: last_reporter-1.2.0rc2-v2.patch
2009-09-28 15:32 gthomas Note Added: 0023040
2009-10-04 20:25 dhx Note Added: 0023054
2009-10-04 20:26 dhx Status new => feedback
2009-10-10 01:54 vboctor Tag Attached: patch
2009-10-12 04:51 gthomas File Added: last_reporter-1.2.0rc2-v3.patch
2009-10-12 04:54 gthomas Note Added: 0023150
2009-10-26 09:02 dhx Note Added: 0023346
2009-10-26 09:02 dhx Assigned To => dhx
2009-10-26 09:02 dhx Status feedback => assigned
2009-10-26 09:02 dhx Target Version => 1.3.0-beta.1
2009-10-27 07:01 dhx File Added: issue10539_v1.diff
2009-10-27 07:21 dhx Note Added: 0023402
2009-10-27 15:28 gthomas Note Added: 0023417
2009-12-30 07:24 gthomas File Added: last_updater.patch
2013-04-27 18:52 atrol Note Added: 0036718
2013-04-27 18:52 atrol Assigned To dhx =>
2013-04-27 18:52 atrol Status assigned => confirmed
2014-01-21 16:59 atrol Target Version 1.3.0-beta.1 =>
2014-10-12 18:36 grangeway Product Version git trunk => 1.3.0-beta.1
2015-03-10 18:07 atrol Relationship added related to 0019476