Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Feb 7, 2022
2 parents e7fcb88 + 8ccb8bc commit 3be867e
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 26 deletions.
31 changes: 31 additions & 0 deletions scripts/misc/addUserPermissionForHubAndProjects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Add hub permission

var userPermission = {};
userPermission.accessLevel = 'admin';
userPermission.entityId = "80b7a1c2-667c-422b-9bd0-e445ee2d9ac8"; //hubId
userPermission.userId = '133855';
userPermission.entityType = 'au.org.ala.ecodata.Hub';
userPermission.status = "active";
db.userPermission.insert(userPermission);

//Add project permissions

var programs = db.hub.findOne({hubId:"80b7a1c2-667c-422b-9bd0-e445ee2d9ac8"}).supportedPrograms;

for (i =0;i<programs.length;i++) {
let program = programs[i];
var projects = db.project.find({associatedProgram: program, status:"active"},{projectId:1, _id:0});
while (projects.hasNext()) {

let project = projects.next();
print(project.projectId)

var userPermission = {};
userPermission.accessLevel = 'admin';
userPermission.entityId = project.projectId;
userPermission.userId = '133855';
userPermission.entityType = 'au.org.ala.ecodata.Project';
userPermission.status = "active";
db.userPermission.insert(userPermission);
}
}
25 changes: 25 additions & 0 deletions scripts/misc/updateBiocollectRecordOwners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//This script can be used to update the record owners (recorded by) of the uploaded records in biocollect

var activityList = db.activity.find({projectActivityId:"", status:"active"})

while (activityList.hasNext()) {
var activity = activityList.next();

if(activity.userId != ""){
activity.userId = ""
}

db.activity.save(activity)
}

var recordList = db.record.find({projectActivityId:"", status:"active"})

while (recordList.hasNext()) {
var record = recordList.next();

if(record.userId != ""){
record.userId = ""
}

db.record.save(record)
}
14 changes: 14 additions & 0 deletions scripts/misc/updatePublicationStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This script provides functionality to update the new field projLifecycleStatus in all existing active biocollect
// projects to Published

print("Start to update projLifecycleStatus");

db.project.update(

{ status: 'active', isMERIT: false },
{ $set: { projLifecycleStatus: true } },
{ upsert: false, multi: true }

)

print("Completed!");
103 changes: 78 additions & 25 deletions scripts/models/bioConditionSiteAssessment/siteBcScoreFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ self.calculateNonNativeSpeciesRichness = function() {
var numNonNativeSpecies = parseInt(self.data.numNonNativeSpecies()) + parseInt(self.data.numUnknownNonNativeSpecies());
var benchmarkSpeciesCoverExotic = self.data.benchmarkSpeciesCoverExotic();
var assessmentPercentage = self.getAssesmentPercentage(benchmarkSpeciesCoverExotic, numNonNativeSpecies);;
self.data.numNonNativeSpeciesTotal(self.getTable12Score(assessmentPercentage));
self.data.numNonNativeSpeciesTotal(numNonNativeSpecies);

var score = self.getTable12Score(self.data.nonNativePlantCoverPercent());
self.data.nonNativePlantCoverScore(score);
Expand All @@ -379,7 +379,8 @@ self.calculateCwdScore = function() {
var bmv10 = (benchmarkValue * 10) / 100;
var bmv50 = (benchmarkValue * 50) / 100;
var bmv200 = (benchmarkValue * 200) / 100;
self.data.cwdScore(self.getTable10Score(totalCwdLength, bmv10, bmv50, bmv200));
//The total measured value should be multiplied by 10 for comparison with the benchmark
self.data.cwdScore(self.getTable10Score(totalCwdLength * 10, bmv10, bmv50, bmv200));
}

};
Expand Down Expand Up @@ -776,11 +777,15 @@ self.data.patchSize.subscribe(function (obj) {
}
});

$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.patchSize()) {
self.data.patchSizeScore(row.value);
}
});
if(self.data.patchSize()=='Not applicable'){
self.data.patchSizeScore(0);}
else {
$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.patchSize()) {
self.data.patchSizeScore(row.value);
}
});
}
self.calculate();
});

Expand All @@ -792,12 +797,15 @@ self.data.connectivity.subscribe(function (obj) {
}
});

$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.connectivity()) {
self.data.connectivityScore(row.value);
}
});

if(self.data.connectivity()=='Not applicable'){
self.data.connectivityScore(0);}
else {
$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.connectivity()) {
self.data.connectivityScore(row.value);
}
});
}
self.calculate();
});

Expand All @@ -810,12 +818,15 @@ self.data.landscapeContext.subscribe(function (obj) {
}
});

$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.landscapeContext()) {
self.data.landscapeContextScore(row.value);
}
});

if(self.data.landscapeContext()=='Not applicable'){
self.data.landscapeContextScore(0);}
else {
$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.landscapeContext()) {
self.data.landscapeContextScore(row.value);
}
});
}
self.calculate();
});

Expand All @@ -827,14 +838,56 @@ self.data.distanceFromWater.subscribe(function (obj) {
}
});

$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.distanceFromWater()) {
self.data.distanceFromWaterScore(row.value);
}
});
if(self.data.distanceFromWater()=='Not applicable'){
self.data.distanceFromWaterScore(0);}
else {
$.grep(table ? table.value : [], function (row) {
if (row.name == self.data.distanceFromWater()) {
self.data.distanceFromWaterScore(row.value);
}
});
}
self.calculate();
});

self.data.isFragmentedLandscape.subscribe(function (obj) {
if(self.data.isFragmentedLandscape() == 'Yes'){
self.data.distanceFromWater('Not applicable');
self.data.distanceFromWaterScore(0);

if(self.data.landscapeContext()=='Not applicable'){
self.data.landscapeContext(null);
self.data.landscapeContextScore(0);
}
if(self.data.connectivity()=='Not applicable'){
self.data.connectivity(null);
self.data.connectivityScore(0);
}
if(self.data.patchSize()=='Not applicable'){
self.data.patchSize(null);
self.data.patchSizeScore(0);
}
}
else{
if(self.data.distanceFromWater()=='Not applicable'){
self.data.distanceFromWater(null);
self.data.distanceFromWaterScore(0);
}
self.data.landscapeContext('Not applicable');
self.data.landscapeContextScore(0);
self.data.connectivity('Not applicable');
self.data.connectivityScore(0);
self.data.patchSize('Not applicable');
self.data.patchSizeScore(0);
}
});
// End of 6.1 Landscaping

self.initialiseReferenceTable();
self.initialiseBenchmark();
self.initialiseBenchmark();

hasBenchmark = function(field, rules, i, options){
if (self.data.hasBenchmark() == "Yes") {
rules.push('required');
}
}
3 changes: 2 additions & 1 deletion scripts/models/bioConditionSiteAssessment/siteBcScoreLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ self.calculateCwdScore = function() {
var bmv10 = (benchmarkValue * 10) / 100;
var bmv50 = (benchmarkValue * 50) / 100;
var bmv200 = (benchmarkValue * 200) / 100;
self.data.cwdScore(self.getTable10Score(totalCwdLength, bmv10, bmv50, bmv200));
//The total measured value should be multiplied by 10 for comparison with the benchmark
self.data.cwdScore(self.getTable10Score(totalCwdLength * 10, bmv10, bmv50, bmv200));
}

};
Expand Down

0 comments on commit 3be867e

Please sign in to comment.