Skip to content

Commit

Permalink
Increase maximum event sub_label length to 100 characters (#6350)
Browse files Browse the repository at this point in the history
* Increase maximum sub label length to 100 characters and update corresponding fields in models and API

* black format...
  • Loading branch information
skrashevich committed May 4, 2023
1 parent 2add675 commit 03b45c1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/docs/integrations/api.md
Expand Up @@ -213,7 +213,7 @@ Sets retain to false for the event id (event may be deleted quickly after removi
### `POST /api/events/<id>/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
{
Expand Down
4 changes: 2 additions & 2 deletions frigate/http.py
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frigate/models.py
Expand Up @@ -14,7 +14,7 @@
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()
Expand Down
12 changes: 12 additions & 0 deletions 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))

0 comments on commit 03b45c1

Please sign in to comment.