]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 add link to Q profile changelog in the events widget
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 24 Jun 2014 08:39:26 +0000 (10:39 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 24 Jun 2014 08:39:35 +0000 (10:39 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/events.html.erb
sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java

index e1cf3f78383a9ef6d17dcaf6f1c9df39e6f4e758..1ee56e96fcf98123d41f819927d7f24af8e4172f 100644 (file)
@@ -65,7 +65,7 @@
 
   <script>
     $j(function() {
-      $j('#select_category_<%= widget.id -%>').select2({ width: '100px' });
+      $j('#select_category_<%= widget.id -%>').select2({ width: '150px' });
     });
   </script>
 
index 3774f9f1b5e6f17b3e27e8eab26ef1ff3b825f3c..cfbed1da0e64eeee6d960bcfaa993531bb7b4429 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.batch.rule;
 
 import com.google.common.collect.ImmutableSortedMap;
+import org.apache.commons.lang.time.DateUtils;
 import org.sonar.api.batch.Decorator;
 import org.sonar.api.batch.DecoratorContext;
 import org.sonar.api.batch.DependsUpon;
@@ -40,6 +41,7 @@ import org.sonar.core.UtcDateUtils;
 
 import javax.annotation.CheckForNull;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -107,9 +109,15 @@ public class QProfileEventsDecorator implements Decorator {
     Event event = new Event();
     event.setName(String.format("Changes in %s", profileLabel(profile)));
     event.setCategory(Event.CATEGORY_PROFILE);
+    Date from = previousProfile.getRulesUpdatedAt();
+
+    // strictly greater than previous date
+    // This hack must be done because date precision is millisecond in db/es and date format is select only
+    from = DateUtils.addSeconds(from, 1);
+
     String data = KeyValueFormat.format(ImmutableSortedMap.of(
       "key", profile.getKey(),
-      "from", UtcDateUtils.formatDateTime(previousProfile.getRulesUpdatedAt()),
+      "from", UtcDateUtils.formatDateTime(from),
       "to", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())));
     event.setData(data);
     persistenceManager.saveEvent(context.getResource(), event);
index c1afcb1e2eed9ddab936d779b358e8741b28ae1d..3d7f46fde693c80efe59c5e22067c5eab2df1360 100644 (file)
@@ -122,7 +122,8 @@ public class QProfileEventsDecoratorTest {
         Event event = (Event) item;
         return event.getCategory().equals(Event.CATEGORY_PROFILE) &&
           "Changes in 'Java One' (Java)".equals(event.getName()) &&
-          "from=2014-01-15T12:00:00+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
+          // "from" is one second more !
+          "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
       }
     }));
   }