From 03b45c153b040824666fa2a0e2cb22a00aada33b Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 5 May 2023 01:59:44 +0300 Subject: [PATCH] Increase maximum event sub_label length to 100 characters (#6350) * Increase maximum sub label length to 100 characters and update corresponding fields in models and API * black format... --- docs/docs/integrations/api.md | 2 +- frigate/http.py | 4 ++-- frigate/models.py | 2 +- migrations/016_sublabel_increase.py | 12 ++++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 migrations/016_sublabel_increase.py diff --git a/docs/docs/integrations/api.md b/docs/docs/integrations/api.md index 9aec392a4..b5b80f3ea 100644 --- a/docs/docs/integrations/api.md +++ b/docs/docs/integrations/api.md @@ -213,7 +213,7 @@ Sets retain to false for the event id (event may be deleted quickly after removi ### `POST /api/events//sub_label` Set a sub label for an event. For example to update `person` -> `person's name` if they were recognized with facial recognition. -Sub labels must be 20 characters or shorter. +Sub labels must be 100 characters or shorter. ```json { diff --git a/frigate/http.py b/frigate/http.py index 66aaff368..94aa5c129 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -375,13 +375,13 @@ def set_sub_label(id): else: new_sub_label = None - if new_sub_label and len(new_sub_label) > 20: + if new_sub_label and len(new_sub_label) > 100: return make_response( jsonify( { "success": False, "message": new_sub_label - + " exceeds the 20 character limit for sub_label", + + " exceeds the 100 character limit for sub_label", } ), 400, diff --git a/frigate/models.py b/frigate/models.py index 3770121cc..0d5f1ab4a 100644 --- a/frigate/models.py +++ b/frigate/models.py @@ -14,7 +14,7 @@ from playhouse.sqlite_ext import JSONField class Event(Model): # type: ignore[misc] id = CharField(null=False, primary_key=True, max_length=30) label = CharField(index=True, max_length=20) - sub_label = CharField(max_length=20, null=True) + sub_label = CharField(max_length=100, null=True) camera = CharField(index=True, max_length=20) start_time = DateTimeField() end_time = DateTimeField() diff --git a/migrations/016_sublabel_increase.py b/migrations/016_sublabel_increase.py new file mode 100644 index 000000000..b46b9fc79 --- /dev/null +++ b/migrations/016_sublabel_increase.py @@ -0,0 +1,12 @@ +import peewee as pw +from playhouse.migrate import * +from playhouse.sqlite_ext import * +from frigate.models import Event + + +def migrate(migrator, database, fake=False, **kwargs): + migrator.change_columns(Event, sub_label=pw.CharField(max_length=100, null=True)) + + +def rollback(migrator, database, fake=False, **kwargs): + migrator.change_columns(Event, sub_label=pw.CharField(max_length=20, null=True))