001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016 017package com.echothree.model.control.search.server.database; 018 019import static com.echothree.model.jooq.server.keys.search.SearchForeignKeys.CACHED_SEARCH_STATUSES_CACHED_SEARCH_FK; 020import static com.echothree.model.jooq.server.tables.search.CachedSearchStatuses.CachedSearchStatuses; 021import static com.echothree.model.jooq.server.tables.search.CachedSearches.CachedSearches; 022import com.echothree.model.data.index.server.entity.Index; 023import com.echothree.util.server.persistence.BaseDatabaseQuery; 024import com.echothree.util.server.persistence.EntityPermission; 025import com.echothree.util.server.persistence.Session; 026import java.util.List; 027 028public class CachedSearchToInvalidateQuery 029 extends BaseDatabaseQuery<CachedSearchToInvalidateResult> { 030 031 public CachedSearchToInvalidateQuery() { 032 super(EntityPermission.READ_WRITE); 033 } 034 035 public List<CachedSearchToInvalidateResult> execute(Index index) { 036 var query = getDslContext() 037 .select(CachedSearchStatuses.CACHED_SEARCH_STATUS.as("CachedSearchStatus")) 038 .from(CachedSearches) 039 .join(CachedSearchStatuses).onKey(CACHED_SEARCH_STATUSES_CACHED_SEARCH_FK) 040 .where(CachedSearches.INDEX.eq(index.getPrimaryKey()), 041 CachedSearches.THRU_TIME.eq(Session.MAX_TIME), 042 CachedSearchStatuses.IS_CONSISTENT.eq(true)); 043 044 return super.execute(query); 045 } 046 047}