Skip to content

Commit

Permalink
filter out deleted tasks in taskCluster (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwarz2030 authored Jun 14, 2022
1 parent b0721e3 commit df36162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class TaskClusterRepository @Inject() (override val db: Database, challengeDAL:
query: Query,
numberOfPoints: Int
): (StringBuilder, List[NamedParameter]) = {
return (new StringBuilder(s"""FROM (
val whereClause = query.filter.sql() + " AND c.deleted = false AND p.deleted = false"

val queryString = s"""FROM (
SELECT tasks.*, tasks.id as taskId, tasks.status as taskStatus,
tasks.priority as taskPriority, tasks.geojson::TEXT as taskGeojson,
task_review.*, c.name as challengeName,
Expand All @@ -90,15 +92,17 @@ class TaskClusterRepository @Inject() (override val db: Database, challengeDAL:
CASE WHEN COUNT(*) < $numberOfPoints THEN COUNT(*) ELSE $numberOfPoints END
FROM tasks
$joinClause
WHERE ${query.filter.sql()}
WHERE ${whereClause}
)::Integer
) OVER () AS kmeans, tasks.location as taskLocation, tasks.parent_id as challengeIds
FROM tasks
$joinClause
WHERE ${query.filter.sql()}
WHERE ${whereClause}
) AS ksub
WHERE location IS NOT NULL
"""), query.parameters())
"""

return (new StringBuilder(queryString), query.parameters())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class TaskClusterService @Inject() (repository: TaskClusterRepository)
params: SearchParameters,
numberOfPoints: Int = this.repository.DEFAULT_NUMBER_OF_POINTS
): List[TaskCluster] = {
val query = this.filterOutDeletedParents(this.filterOnSearchParameters(params)(false))
val filtered = this.filterOnSearchParameters(params)(false)
val query = this.filterOutDeletedParents(filtered)

this.repository.queryTaskClusters(query, numberOfPoints, params)
}

Expand Down

0 comments on commit df36162

Please sign in to comment.