AND u.last_connection_date >= #{query.lastConnectionDateFrom, jdbcType=BIGINT}
</if>
<if test="query.lastConnectionDateTo != null">
- AND u.last_connection_date < #{query.lastConnectionDateTo, jdbcType=BIGINT}
+ AND (u.last_connection_date is null or u.last_connection_date < #{query.lastConnectionDateTo, jdbcType=BIGINT})
</if>
<if test="query.sonarLintLastConnectionDateFrom != null">
AND u.last_sonarlint_connection >= #{query.sonarLintLastConnectionDateFrom, jdbcType=BIGINT}
</if>
<if test="query.sonarLintLastConnectionDateTo != null">
- AND u.last_sonarlint_connection < #{query.sonarLintLastConnectionDateTo, jdbcType=BIGINT}
+ AND (u.last_sonarlint_connection is null or u.last_sonarlint_connection < #{query.sonarLintLastConnectionDateTo, jdbcType=BIGINT})
</if>
</where>
</sql>
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();
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)
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)
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)
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)