]> source.dussan.org Git - sonarqube.git/commitdiff
[SONAR-18964] the sonarlint and SQ last connected before request fields now includes...
authorSteve Marion <steve.marion@sonarsource.com>
Fri, 14 Apr 2023 15:15:09 +0000 (17:15 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 17 Apr 2023 20:02:52 +0000 (20:02 +0000)
server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml
server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/SearchActionIT.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SearchAction.java

index 791f63c990c7d494b421ff11ecbe33dbd847dc4f..3f0612c39a1d792074b2028e3239585d4c7709c3 100644 (file)
                 AND u.last_connection_date &gt;= #{query.lastConnectionDateFrom, jdbcType=BIGINT}
             </if>
             <if test="query.lastConnectionDateTo != null">
-                AND u.last_connection_date &lt; #{query.lastConnectionDateTo, jdbcType=BIGINT}
+                AND (u.last_connection_date is null or u.last_connection_date &lt; #{query.lastConnectionDateTo, jdbcType=BIGINT})
             </if>
             <if test="query.sonarLintLastConnectionDateFrom != null">
                 AND u.last_sonarlint_connection &gt;= #{query.sonarLintLastConnectionDateFrom, jdbcType=BIGINT}
             </if>
             <if test="query.sonarLintLastConnectionDateTo != null">
-                AND u.last_sonarlint_connection &lt; #{query.sonarLintLastConnectionDateTo, jdbcType=BIGINT}
+                AND (u.last_sonarlint_connection is null or u.last_sonarlint_connection &lt; #{query.sonarLintLastConnectionDateTo, jdbcType=BIGINT})
             </if>
         </where>
     </sql>
index db71e878feaab3ee2bbcef705f3393967e2532f1..4a4c315715d284b3573a2230a0e1932856d141ef 100644 (file)
@@ -529,6 +529,25 @@ public class SearchActionIT {
     assertUserWithFilter(SearchAction.SONAR_LINT_LAST_CONNECTION_DATE_TO, lastConnection, user.getLogin(), true);
   }
 
+
+  @Test
+  public void search_whenNoLastConnection_shouldReturnForBeforeOnly() {
+    userSession.logIn().setSystemAdministrator();
+    final Instant lastConnection = Instant.now();
+    UserDto user = db.users().insertUser(u -> u
+      .setLogin("user-%_%-login")
+      .setName("user-name")
+      .setEmail("user@mail.com")
+      .setLocal(true)
+      .setScmAccounts(singletonList("user1")));
+
+    assertUserWithFilter(SearchAction.LAST_CONNECTION_DATE_FROM, lastConnection, user.getLogin(), false);
+    assertUserWithFilter(SearchAction.LAST_CONNECTION_DATE_TO, lastConnection, user.getLogin(), true);
+
+    assertUserWithFilter(SearchAction.SONAR_LINT_LAST_CONNECTION_DATE_FROM, lastConnection, user.getLogin(), false);
+    assertUserWithFilter(SearchAction.SONAR_LINT_LAST_CONNECTION_DATE_TO, lastConnection, user.getLogin(), true);
+  }
+
   @Test
   public void search_whenNotAdmin_shouldThrowForbidden() {
     userSession.logIn();
index 1f83f093fdec1d45ed47513f56180b6755b9a7d1..e0d3e4d8b7a17ecf0bc7fc54e0494b23832571b2 100644 (file)
@@ -146,7 +146,8 @@ public class SearchAction implements UsersWsAction {
     action.createParam(LAST_CONNECTION_DATE_FROM)
       .setSince("10.1")
       .setDescription("""
-        Filter the users based on the last connection date field. Only users who interacted with this instance at or after the date will be returned.
+        Filter the users based on the last connection date field.
+        Only users who interacted with this instance at or after the date will be returned.
         The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)""")
       .setRequired(false)
       .setDefaultValue(null)
@@ -154,7 +155,8 @@ public class SearchAction implements UsersWsAction {
     action.createParam(LAST_CONNECTION_DATE_TO)
       .setSince("10.1")
       .setDescription("""
-        Filter the users based on the last connection date field. Only users who interacted with this instance at or before the date will be returned.
+        Filter the users based on the last connection date field.
+        Only users that never connected or who interacted with this instance at or before the date will be returned.
         The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)""")
       .setRequired(false)
       .setDefaultValue(null)
@@ -162,7 +164,8 @@ public class SearchAction implements UsersWsAction {
     action.createParam(SONAR_LINT_LAST_CONNECTION_DATE_FROM)
       .setSince("10.1")
       .setDescription("""
-        Filter the users based on the sonar lint last connection date field. Only users who interacted with this instance using SonarLint at or after the date will be returned.
+        Filter the users based on the sonar lint last connection date field 
+        Only users who interacted with this instance using SonarLint at or after the date will be returned.
         The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)""")
       .setRequired(false)
       .setDefaultValue(null)
@@ -170,7 +173,8 @@ public class SearchAction implements UsersWsAction {
     action.createParam(SONAR_LINT_LAST_CONNECTION_DATE_TO)
       .setSince("10.1")
       .setDescription("""
-        Filter the users based on the sonar lint last connection date field. Only users who interacted with this instance using SonarLint at or before the date will be returned.
+        Filter the users based on the sonar lint last connection date field.
+        Only users that never connected or who interacted with this instance using SonarLint at or before the date will be returned.
         The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)""")
       .setRequired(false)
       .setDefaultValue(null)