Skip to content

Commit aa8063e

Browse files
committed
fix observation collection inclusion based on media rules
1 parent b1022ef commit aa8063e

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

lib/models/project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ const Project = class Project extends Model {
372372
if ( field === "quality_grade" && !_.includes( value, observation.quality_grade ) ) {
373373
return false;
374374
}
375-
if ( field === "photos" && ( _.isEmpty( observation.photos ) || observation.photos_count === 0 ) ) {
375+
if ( field === "photos" && _.isEmpty( observation.photos ) ) {
376376
return false;
377377
}
378-
if ( field === "sounds" && ( _.isEmpty( observation.sounds ) || observation.sounds_count === 0 ) ) {
378+
if ( field === "sounds" && _.isEmpty( observation.sounds ) ) {
379379
return false;
380380
}
381381
if ( field === "native" && !observation.taxon?.native ) {

test/models/project.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,11 @@ describe( "Project", ( ) => {
436436

437437
it( "photos requires photos to be present", ( ) => {
438438
project = buildProject( { photos: true } );
439-
observation = { photos_count: 1, photos: [{ id: 1 }] };
439+
observation = { photos: [{ id: 1 }] };
440440
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.true;
441-
observation = { photos_count: 1, photos: [] };
441+
observation = { photos: [] };
442442
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
443-
observation = { photos_count: 0, photos: [{ id: 1 }] };
444-
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
445-
observation = { photos_count: 0 };
446-
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
447-
observation = { sounds_count: 1, sounds: [{ id: 1 }] };
443+
observation = { sounds: [{ id: 1 }] };
448444
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
449445

450446
observation = { };
@@ -453,15 +449,11 @@ describe( "Project", ( ) => {
453449

454450
it( "sounds requires sounds to be present", ( ) => {
455451
project = buildProject( { sounds: true } );
456-
observation = { sounds_count: 1, sounds: [{ id: 1 }] };
452+
observation = { sounds: [{ id: 1 }] };
457453
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.true;
458-
observation = { sounds_count: 1, sounds: [] };
459-
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
460-
observation = { sounds_count: 0, sounds: [{ id: 1 }] };
461-
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
462-
observation = { sounds_count: 0 };
454+
observation = { sounds: [] };
463455
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
464-
observation = { photos_count: 1, photos: [{ id: 1 }] };
456+
observation = { photos: [{ id: 1 }] };
465457
expect( Project.collectionProjectRulesAllowObservation( project, observation ) ).to.be.false;
466458

467459
observation = { };

0 commit comments

Comments
 (0)