mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-02 08:28:48 +01:00
Carry qualified card search repair through 18380
Normal parent merge; only the five qualified card/search paths change. Preserve every other owned and upstream blob. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
commit
cf87b23cbd
5 files changed
+141
-12
No files matched your search
@@ -548,7 +548,9 @@ export function companySearchService(db: Db) {
|
||||
search: async (
|
||||
companyId: string,
|
||||
query: CompanySearchQuery,
|
||||
options?: { issueReadCondition?: SQL<boolean>; projectReadCondition?: SQL<boolean>; onNextMembershipChange?: (at: Date | null) => void },
|
||||
options?: { issueReadCondition?: SQL<boolean>; projectReadCondition?: SQL<boolean>; onNextMembershipChange?: (at: Date | null) => void;
|
||||
/** Restrict result kinds before pagination; retain the requested text-match scope. */
|
||||
issueResultsOnly?: boolean },
|
||||
): Promise<CompanySearchResponse> => {
|
||||
const taskSearch = parseTaskSearch(query.q);
|
||||
const normalizedQuery = taskSearch.normalizedQuery;
|
||||
@@ -558,7 +560,7 @@ export function companySearchService(db: Db) {
|
||||
const sort = query.sort;
|
||||
const limit = query.limit;
|
||||
const offset = query.offset;
|
||||
if (!hasSearchText && !issueOnlyFiltersActive(query)) {
|
||||
if ((!hasSearchText && !issueOnlyFiltersActive(query)) || (options?.issueResultsOnly && !scopeIncludesIssues(scope))) {
|
||||
options?.onNextMembershipChange?.(null);
|
||||
return {
|
||||
query: query.q,
|
||||
@@ -894,7 +896,7 @@ export function companySearchService(db: Db) {
|
||||
const projectReadCondition = options?.projectReadCondition ?? sql<boolean>`true`;
|
||||
|
||||
async function fetchAgentRows() {
|
||||
if (!hasSearchText || !scopeIncludesAgents(scope) || hasIssueOnlyFilters) return [];
|
||||
if (options?.issueResultsOnly || !hasSearchText || !scopeIncludesAgents(scope) || hasIssueOnlyFilters) return [];
|
||||
return db
|
||||
.select({
|
||||
id: agents.id,
|
||||
@@ -911,7 +913,7 @@ export function companySearchService(db: Db) {
|
||||
}
|
||||
|
||||
async function fetchProjectRows() {
|
||||
if (!hasSearchText || !scopeIncludesProjects(scope) || hasIssueOnlyFilters) return [];
|
||||
if (options?.issueResultsOnly || !hasSearchText || !scopeIncludesProjects(scope) || hasIssueOnlyFilters) return [];
|
||||
return db
|
||||
.select({
|
||||
id: projects.id,
|
||||
@@ -927,7 +929,7 @@ export function companySearchService(db: Db) {
|
||||
}
|
||||
|
||||
async function countArtifacts(filters: CompanySearchQuery = query) {
|
||||
if (!hasSearchText) return 0;
|
||||
if (options?.issueResultsOnly || !hasSearchText) return 0;
|
||||
const artifactIssueFilters = issueFilterConditions(companyId, filters);
|
||||
const artifactIssueConditions = [
|
||||
eq(issues.companyId, companyId),
|
||||
@@ -995,7 +997,7 @@ export function companySearchService(db: Db) {
|
||||
}
|
||||
|
||||
async function countAgents(filters: CompanySearchQuery = query) {
|
||||
if (!hasSearchText || issueOnlyFiltersActive(filters)) return 0;
|
||||
if (options?.issueResultsOnly || !hasSearchText || issueOnlyFiltersActive(filters)) return 0;
|
||||
const rows = await db
|
||||
.select({ count: sql<number>`count(*)::int` })
|
||||
.from(agents)
|
||||
@@ -1004,7 +1006,7 @@ export function companySearchService(db: Db) {
|
||||
}
|
||||
|
||||
async function countProjects(filters: CompanySearchQuery = query) {
|
||||
if (!hasSearchText || issueOnlyFiltersActive(filters)) return 0;
|
||||
if (options?.issueResultsOnly || !hasSearchText || issueOnlyFiltersActive(filters)) return 0;
|
||||
const rows = await db
|
||||
.select({ count: sql<number>`count(*)::int` })
|
||||
.from(projects)
|
||||
@@ -1013,7 +1015,7 @@ export function companySearchService(db: Db) {
|
||||
}
|
||||
|
||||
async function fetchArtifactRows() {
|
||||
if (!hasSearchText || !scopeIncludesArtifacts(scope)) return [];
|
||||
if (options?.issueResultsOnly || !hasSearchText || !scopeIncludesArtifacts(scope)) return [];
|
||||
const result = await companyArtifactsService(db).list(companyId, {
|
||||
q: normalizedQuery.slice(0, COMPANY_ARTIFACTS_MAX_QUERY_LENGTH),
|
||||
limit: Math.min(fetchLimit, COMPANY_ARTIFACTS_MAX_LIMIT),
|
||||
|
||||
@@ -601,7 +601,7 @@ export function statusCardService(
|
||||
for (const storedQuery of card.queries) {
|
||||
const query = companySearchQuerySchema.parse(storedQuery);
|
||||
const response = await companySearchService(queryDb).search(card.companyId, query, {
|
||||
issueReadCondition: options.issueReadCondition, onNextMembershipChange,
|
||||
issueReadCondition: options.issueReadCondition, onNextMembershipChange, issueResultsOnly: true,
|
||||
});
|
||||
for (const result of response.results) {
|
||||
if (result.type === "issue" && result.issue) issueMap.set(result.issue.id, result.issue);
|
||||
@@ -1049,7 +1049,7 @@ export function statusCardService(
|
||||
return {
|
||||
query,
|
||||
result: await searchSvc.search(card.companyId, query, {
|
||||
issueReadCondition: options.issueReadCondition,
|
||||
issueReadCondition: options.issueReadCondition, issueResultsOnly: true,
|
||||
}),
|
||||
};
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user