private void clean() {
        info(() -> "Starting history clean task");

        final int historyItemsRetention = storedQueryConfig.getItemsRetention();
        final int historyDaysRetention = storedQueryConfig.getDaysRetention();

        final long oldestCrtMs = Instant.now()
                .minus(historyDaysRetention, ChronoUnit.DAYS)
                .toEpochMilli();

        final Set<String> userUuids = storedQueryDao.getUsersWithNonFavourites();
        LOGGER.debug(() -> LogUtil.message("Found {} userUuids", userUuids.size()));

        userUuids.forEach(ownerUuid -> {
            final String userDisplayName = userRefLookup.getByUuid(ownerUuid)
                    .map(UserRef::toInfoString)
                    .orElse("?");

            info(() -> "Cleaning query history for user '" + userDisplayName
                       + "' with ownerUuid '" + ownerUuid + "'");

            storedQueryDao.clean(ownerUuid, historyItemsRetention, oldestCrtMs);
        });

        info(() -> "Finished history clean task");
    }
Delete all non-favourite stored queries
stroom-dashboard/stroom-storedquery-impl/src/main/java/stroom/storedquery/impl/StoredQueryHistoryCleanExecutor.java