biigle / core

:large_blue_circle: Application core of BIIGLE
https://biigle.de
GNU General Public License v3.0
12 stars 15 forks source link

Remove null (gap) to prevent validation errors #728

Closed lehecht closed 8 months ago

lehecht commented 9 months ago

If single frame and clip annotations are linked and are not touching each other, then null is added. When deleting the single frame annotation, delete also the null.

Fix #488

mzur commented 9 months ago

There is still an error if I put the single-frame annotation before the multi-frame annotation.

lehecht commented 9 months ago

I found a related bug. If you delete an annotation within a multiframe annotation, which is bordered by single frame annotations on each side, you will get the error message Invalid number of points for shape Point!. It occurs for all shapes, with whom you can create a multiframe annotation.

mzur commented 9 months ago

If you delete an annotation within a multiframe annotation, which is bordered by single frame annotations on each side, you will get the error message Invalid number of points for shape Point!.

Could you please also fix this in this PR?

lehecht commented 8 months ago

@mzur you can check it out now.

mzur commented 8 months ago

I have pushed the implementation of my idea and I still think it works. Can you please test it, too?

lehecht commented 8 months ago

@mzur it works. And now I understood what you meant. I was really confused before. Thanks!

mzur commented 8 months ago

Sorry, I'll try to be more clear next time :wink: Do we still need the other change? If yes, please move it to the VideoAnnotation model.

lehecht commented 8 months ago

The test should be written in a way that would fail before the change and pass with the change.

What do you mean by that? The change is implemented within the model, so it is always tested if the array is empty or not.

mzur commented 8 months ago

I would like to have a test like this one that checks the new behavior of validating an annotation with a gap. If the test would be executed before the changes of this PR, it should fail. After the changes of this PR, the test should pass.

lehecht commented 8 months ago

For me it sounds like, you want something like this. That is why I'm still confused, because the whole test will always fail.

$this->model->shape_id = Shape::pointId();
$this->model->points = [[]];
$this->model->validatePoints(); // does not fail
$this->expectException(Exception::class);
$this->model->points = [[]];
$this->model->validatePoints(); // should fail, but does not
mzur commented 8 months ago

I meant something like this: https://github.com/biigle/core/pull/728/commits/16d1f2a37bad6272790f03bb1e315ea21897e9f1

Before your change, this would fail, although it is perfectly valid. We could even extend the validation so it checks that there are no consecutive empty arrays or there is a mismatch between the empty array position and the null but I think we don't have to overengineer this now.