{
  "title": "Jobs",
  "icon": "gearshape.2",
  "sidebar": false,
  "sources": {
    "queues": {
      "url": "http://192.0.2.40:2283",
      "secret": "immich",
      "auth": {
        "type": "header",
        "name": "x-api-key"
      },
      "every": "1m",
      "requests": {
        "queues": "/api/queues"
      },
      "derive": [
        {
          "name": "q_failed",
          "value": {
            "each": "queues",
            "where": {
              "path": "statistics.failed",
              "gt": 0
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_paused",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "isPaused",
                  "equals": true
                },
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "any": [
                    {
                      "path": "statistics.active",
                      "gt": 0
                    },
                    {
                      "path": "statistics.waiting",
                      "gt": 0
                    }
                  ]
                }
              ]
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_working",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "isPaused",
                  "equals": false
                },
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "any": [
                    {
                      "path": "statistics.active",
                      "gt": 0
                    },
                    {
                      "path": "statistics.waiting",
                      "gt": 0
                    }
                  ]
                }
              ]
            },
            "sort": {
              "by": "statistics.waiting",
              "order": "desc"
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_idle",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "path": "statistics.active",
                  "equals": 0
                },
                {
                  "path": "statistics.waiting",
                  "equals": 0
                }
              ]
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "failed_total",
          "value": {
            "sum": "statistics.failed",
            "of": "queues",
            "default": 0
          }
        },
        {
          "name": "busy_total",
          "value": {
            "sum": "busy",
            "of": "q_working",
            "default": 0
          }
        },
        {
          "name": "failed_first",
          "value": {
            "first": "text",
            "of": "q_failed"
          }
        },
        {
          "name": "failed_queues",
          "value": {
            "count": "q_failed",
            "default": 0
          }
        },
        {
          "name": "shown",
          "value": {
            "each": [
              "q_failed",
              "q_paused",
              "q_working"
            ],
            "fields": {
              "name": "name"
            }
          }
        },
        {
          "name": "shown_count",
          "value": {
            "count": "shown",
            "default": 0
          }
        }
      ]
    }
  },
  "cards": [
    {
      "id": "queues",
      "type": "list",
      "items": [],
      "source": {
        "ref": "queues",
        "map": {
          "items": {
            "each": [
              "q_failed",
              "q_paused",
              "q_working",
              "q_idle"
            ],
            "fields": {
              "text": "text",
              "detail": "detail",
              "name": "name",
              "failed": "failed",
              "paused": "paused",
              "failed_words": "failed_words"
            }
          }
        }
      },
      "row_actions": [
        {
          "label": "Pause",
          "icon": "pause.fill",
          "method": "PUT",
          "path": "/api/queues/{name}",
          "body": {
            "isPaused": true
          },
          "when": {
            "path": "paused",
            "equals": false
          }
        },
        {
          "label": "Resume",
          "icon": "play.fill",
          "method": "PUT",
          "path": "/api/queues/{name}",
          "body": {
            "isPaused": false
          },
          "when": {
            "path": "paused",
            "equals": true
          }
        },
        {
          "label": "Clear failed",
          "icon": "xmark.circle",
          "method": "PUT",
          "path": "/api/jobs/{name}",
          "body": {
            "command": "clear-failed",
            "force": false
          },
          "confirm": {
            "message": "Clear {failed_words} from {text}? Immich won't retry them.",
            "button": "Clear"
          },
          "when": {
            "path": "failed",
            "gt": 0
          }
        }
      ]
    }
  ]
}
