Skip to content

Commit

Permalink
this maybe optional as well
Browse files Browse the repository at this point in the history
  • Loading branch information
peregrineshahin committed Jul 27, 2024
1 parent ea8d9bf commit a76568a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/fishtest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def size_is_length(x):
"worker_name": short_worker_name,
"blocked": bool,
"message?": worker_message, # old field, todo: remove this field from db if exists
"notes": intersect(
"notes?": intersect(
[
{"time": datetime_utc, "username": username, "message": worker_message},
...,
Expand Down

1 comment on commit a76568a

@vdbergh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to enforce that either "message" or "notes" is present then you can do it as follows.

worker_schema = intersect(
  {
      "_id?": ObjectId,
      "worker_name": short_worker_name,
      "blocked": bool,
      "message?": worker_message,  # old field, todo: remove this field from db if exists
      "notes?": intersect(
          [
              {"time": datetime_utc, "username": username, "message": worker_message},
              ...,
          ],
          size(0, 100),  # new field, todo: add this field to db if it doesn't exists
      ),
      "last_updated": datetime_utc,
  },
  one_of("message", "notes"),
)

Please sign in to comment.