MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / FilterTasks

Function FilterTasks

internal/ui/models/state.go:265–331  ·  view source on GitHub ↗

FilterTasks filters the tasks based on the given search string.

(filter string)

Source from the content-addressed store, hash-verified

263
264// FilterTasks filters the tasks based on the given search string.
265func FilterTasks(filter string) {
266 if filter == "" {
267 // No filter, use all tasks
268 GlobalState.FilteredTasks = make([]*api.ClusterTask, len(GlobalState.OriginalTasks))
269 copy(GlobalState.FilteredTasks, GlobalState.OriginalTasks)
270
271 return
272 }
273
274 // Convert filter to lowercase for case-insensitive search
275 filter = strings.ToLower(filter)
276
277 // Create a new filtered list
278 GlobalState.FilteredTasks = make([]*api.ClusterTask, 0)
279
280 // Add tasks that match the filter
281 for _, task := range GlobalState.OriginalTasks {
282 if task == nil {
283 continue
284 }
285
286 // Check task ID
287 if strings.Contains(strings.ToLower(task.ID), filter) {
288 GlobalState.FilteredTasks = append(GlobalState.FilteredTasks, task)
289
290 continue
291 }
292
293 // Check task node
294 if strings.Contains(strings.ToLower(task.Node), filter) {
295 GlobalState.FilteredTasks = append(GlobalState.FilteredTasks, task)
296
297 continue
298 }
299
300 // Check task type
301 if strings.Contains(strings.ToLower(task.Type), filter) {
302 GlobalState.FilteredTasks = append(GlobalState.FilteredTasks, task)
303
304 continue
305 }
306
307 // Check task status
308 if strings.Contains(strings.ToLower(task.Status), filter) {
309 GlobalState.FilteredTasks = append(GlobalState.FilteredTasks, task)
310
311 continue
312 }
313
314 // Check task user
315 if strings.Contains(strings.ToLower(task.User), filter) {
316 GlobalState.FilteredTasks = append(GlobalState.FilteredTasks, task)
317
318 continue
319 }
320
321 // Check UPID
322 if strings.Contains(strings.ToLower(task.UPID), filter) {

Callers 3

loadTasksDataMethod · 0.92
autoRefreshDataMethod · 0.92
activateSearchMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected