The DAO for SearchResult.
| 18 | |
| 19 | /** The DAO for {@link SearchResult}. */ |
| 20 | @RegisterRowMapper(SearchResultMapper.class) |
| 21 | public interface SearchDao extends SqlObject { |
| 22 | |
| 23 | default List<SearchResult> search(String query, SearchFilter filter, SearchSort sort, int limit) { |
| 24 | return search(query, filter, sort, limit, null, null, null); |
| 25 | } |
| 26 | |
| 27 | default List<SearchResult> search( |
| 28 | String query, SearchFilter filter, SearchSort sort, int limit, String namespace) { |
| 29 | return search(query, filter, sort, limit, namespace, null, null); |
| 30 | } |
| 31 | |
| 32 | default List<SearchResult> search( |
| 33 | String query, SearchFilter filter, SearchSort sort, int limit, LocalDate before) { |
| 34 | return search(query, filter, sort, limit, null, before, null); |
| 35 | } |
| 36 | |
| 37 | default List<SearchResult> search( |
| 38 | String query, |
| 39 | SearchFilter filter, |
| 40 | SearchSort sort, |
| 41 | int limit, |
| 42 | LocalDate before, |
| 43 | LocalDate after) { |
| 44 | return search(query, filter, sort, limit, null, before, after); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns all datasets and jobs that match the provided query; matching of datasets and jobs are |
| 49 | * string based and case-insensitive. |
| 50 | * |
| 51 | * @param query Query containing pattern to match. |
| 52 | * @param filter The filter to apply to the query result. |
| 53 | * @param sort The sort to apply to the query result. |
| 54 | * @param limit The limit to apply to the query result. |
| 55 | * @param namespace Match jobs or datasets within the given namespace. |
| 56 | * @param before Match jobs or datasets before YYYY-MM-DD. |
| 57 | * @param after Match jobs or datasets after YYYY-MM-DD. |
| 58 | * @return A {@link SearchResult} object. |
| 59 | */ |
| 60 | @SqlQuery( |
| 61 | """ |
| 62 | SELECT type, name, updated_at, namespace_name |
| 63 | FROM ( |
| 64 | SELECT 'DATASET' AS type, d.name, d.updated_at, d.namespace_name |
| 65 | FROM datasets_view AS d |
| 66 | WHERE (d.namespace_name = :namespace OR CAST(:namespace AS TEXT) IS NULL) |
| 67 | AND (d.updated_at < :before OR CAST(:before AS TEXT) IS NULL) |
| 68 | AND (d.updated_at > :after OR CAST(:after AS TEXT) IS NULL) |
| 69 | AND (d.name ILIKE '%' || :query || '%') |
| 70 | UNION |
| 71 | SELECT DISTINCT ON (j.namespace_name, j.name) |
| 72 | 'JOB' AS type, j.name, j.updated_at, j.namespace_name |
| 73 | FROM (SELECT namespace_name, name, UNNEST(COALESCE(aliases, Array[NULL]::varchar[])) AS alias, updated_at |
| 74 | FROM jobs_view WHERE symlink_target_uuid IS NULL |
| 75 | ORDER BY updated_at DESC) AS j |
| 76 | WHERE (j.namespace_name = :namespace OR CAST(:namespace AS TEXT) IS NULL) |
| 77 | AND (j.updated_at < :before OR CAST(:before AS TEXT) IS NULL) |
no outgoing calls
no test coverage detected