Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
robertgodfrey committed Nov 9, 2023
1 parent 6ed3061 commit 7dc1656
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
12 changes: 8 additions & 4 deletions my-app/src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ export const ISLANDS = [
"Maui",
"Molokai",
"Lanai",
"Kahoolawe",
"Oahu",
"Kauai",
"Niihau",
"NWHI",
"At-sea Offshore"
]
];

export const STORAGE_NODES = [
"CMDR Hub",
"Maui Node",
"Big Island Node",
"Kauai Node",
];
10 changes: 3 additions & 7 deletions my-app/src/models/event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISLANDS } from "@/constants/constants";
import { ISLANDS, STORAGE_NODES } from "@/constants/constants";
import mongoose from "mongoose";

// subdocument schema
Expand Down Expand Up @@ -103,10 +103,6 @@ const eventSchema = new mongoose.Schema({
imageUrl: {
type: String,
},
dibsByOrgId: {
type: String,
trim: true,
},
removedByOrgId: {
type: String,
trim: true,
Expand All @@ -126,8 +122,8 @@ const eventSchema = new mongoose.Schema({
trim: true,
},
tempStorage: {
type: Number,
trim: true,
type: String,
enum: STORAGE_NODES,
},
assessedEnvDamage: {
type: String,
Expand Down
8 changes: 7 additions & 1 deletion my-app/src/models/organization.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mongoose, { Schema } from "mongoose";
import { ISLANDS, STORAGE_NODES } from "@/constants/constants";

const organizationSchema = new Schema({
name: {
Expand All @@ -8,7 +9,12 @@ const organizationSchema = new Schema({
},
location: {
type: String,
enum: ["Oahu", "Maui", "Big Island", "Kauai"],
enum: ISLANDS,
required: true,
},
associatedNode: {
type: String,
enum: STORAGE_NODES,
required: true,
}
});
Expand Down
4 changes: 2 additions & 2 deletions my-app/src/utils/findCloseIsland.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export function findCloseIsland(lat, long) {
return 'Lanai';
}
if (Math.sqrt((lat - kahoolaweCenter[0]) ** 2 + (long - kahoolaweCenter[1]) ** 2) <= kahoolaweRadiusBoundary) {
return 'Kahoolawe';
return 'Maui';
}
if (Math.sqrt((lat - centerNiiahu[0]) ** 2 + (long - centerNiiahu[1]) ** 2) <= niiahuRadiusBoundary) {
return 'Niihau';
return 'Kauai';
}
return 'At-sea Offshore';
}

0 comments on commit 7dc1656

Please sign in to comment.