LCOV - code coverage report
Current view: top level - src/platform/customNodes/manager/utils - nodePackSort.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 50.0 % 10 5
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { components } from '@/types/comfyRegistryTypes'
       2              : import { SortableAlgoliaField } from '@/platform/customNodes/manager/types/comfyManagerTypes'
       3              : 
       4              : type NodePack = components['schemas']['Node']
       5              : 
       6              : export interface SortableField<T = string> {
       7              :   id: T
       8              :   label: string
       9              :   direction: 'asc' | 'desc'
      10              : }
      11              : 
      12         2355 : export const PACK_SORTABLE_FIELDS: SortableField[] = [
      13              :   { id: SortableAlgoliaField.Downloads, label: 'Downloads', direction: 'desc' },
      14              :   { id: SortableAlgoliaField.Created, label: 'Created', direction: 'desc' },
      15              :   { id: SortableAlgoliaField.Updated, label: 'Updated', direction: 'desc' },
      16              :   { id: SortableAlgoliaField.Publisher, label: 'Publisher', direction: 'asc' },
      17              :   { id: SortableAlgoliaField.Name, label: 'Name', direction: 'asc' }
      18              : ]
      19              : 
      20         2355 : const toTime = (value: string | undefined | null): number =>
      21              :   value ? new Date(value).getTime() : 0
      22              : 
      23         2355 : export const getPackSortValue = (
      24              :   pack: NodePack,
      25              :   field: string
      26              : ): string | number => {
      27            2 :   switch (field) {
      28              :     case SortableAlgoliaField.Downloads:
      29            2 :       return pack.downloads ?? 0
      30              :     case SortableAlgoliaField.Created:
      31            0 :       return toTime(pack.created_at)
      32              :     case SortableAlgoliaField.Updated:
      33            0 :       return toTime(pack.latest_version?.createdAt)
      34              :     case SortableAlgoliaField.Publisher:
      35            0 :       return pack.publisher?.name ?? ''
      36              :     case SortableAlgoliaField.Name:
      37            0 :       return pack.name ?? ''
      38              :     default:
      39            0 :       return 0
      40              :   }
      41              : }
        

Generated by: LCOV version 2.0-1