Skip to content

Commit

Permalink
Update Exists function
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Jun 13, 2024
1 parent 39cbf1a commit fa71408
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 124 deletions.
32 changes: 21 additions & 11 deletions api/lib/api/mission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,28 @@ export default class {
name: string,
opts?: Static<typeof MissionOptions>
): Promise<boolean> {
const url = new URL(`/Marti/api/missions/${this.#encodeName(name)}`, this.api.url);

try {
if (this.#isGUID(name)) return await this.getGuid(name, {}, opts);

const missions: TAKList<Static<typeof Mission>> = await this.api.fetch(url, {
method: 'GET',
headers: this.#headers(opts),
});

if (!missions.data.length) return false;
return true;
if (this.#isGUID(name)) {
const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(name)}`, this.api.url);

const missions: TAKList<Static<typeof Mission>> = await this.api.fetch(url, {
method: 'GET',
headers: this.#headers(opts),
});

if (!missions.data.length) return false;
return true;
} else {
const url = new URL(`/Marti/api/missions/${this.#encodeName(name)}`, this.api.url);

const missions: TAKList<Static<typeof Mission>> = await this.api.fetch(url, {
method: 'GET',
headers: this.#headers(opts),
});

if (!missions.data.length) return false;
return true;
}
} catch (err) {
return false;
}
Expand Down
6 changes: 2 additions & 4 deletions api/routes/connection-layer-cot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,19 @@ export default async function router(schema: Schema, config: Config) {
for (const feat of req.body.features) {
const cot = CoT.from_geojson(feat);

/*
const exist = existMap.get(String(feat.id));
if (exist && data.mission_diff) {
const b = CoT.from_geojson(exist);
if (!cot.isDiff(b)) continue;
}
*/

cot.addDest({ mission: data.name, path: `layer-${layer.id}` });
cot.addDest({ mission: data.name });
cots.push(cot)
}
} else {
for (const feat of req.body.features) {
const cot = CoT.from_geojson(feat);
cot.addDest({ mission: data.name, path: `layer-${layer.id}` });
cot.addDest({ mission: data.name });
cots.push(cot)
}
}
Expand Down
1 change: 0 additions & 1 deletion api/routes/profile-overlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default async function router(schema: Schema, config: Config) {
overlays.total--;
} else if (item.mode === 'mission' && !(await api.Mission.exists(
item.mode_id,
req.query,
await config.conns.subscription(user.email, item.name)
))
) {
Expand Down
Loading

0 comments on commit fa71408

Please sign in to comment.