Skip to content

Commit

Permalink
rename encounters with generate search tables
Browse files Browse the repository at this point in the history
  • Loading branch information
HarmlessHarm committed Nov 17, 2023
1 parent 37b39a1 commit dd27e1c
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/views/Admin/GenerateSearchTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,32 @@ export default {
if (encounter.encounter !== undefined) {
if (encounter.name === undefined) {
// Encounter name stored in .encounter should be in .name
await db.ref(`encounters/${uid}/${cid}/${key}/name`).set(entry.encounter);
await db.ref(`encounters/${uid}/${cid}/${key}/name`).set(encounter.encounter);
encounter.name = encounter.encounter;
}
// .encounter should be removed
await db.ref(`encounters/${uid}/${cid}/${key}/encounter`).remove();
delete encounter.encounter;
}
// const search_entry = this.extractFields(entry, this.search_fields[this.ref]);
// const search_ref = db.ref(`${this.search_ref[this.ref]}/${uid}/results/${cid}/${key}`);
// try {
// // await search_ref.set(search_entry)
// } catch(error) {
// console.error(`Couldn't update ${this.search_ref[this.ref]} table`, key, entry.name, error, search_entry)
// }
const search_entry = this.extractFields(encounter, this.search_fields[this.ref]);
const search_ref = db.ref(
`${this.search_ref[this.ref]}/${uid}/results/${cid}/${key}`
);
try {
await search_ref.set(search_entry);
} catch (error) {
console.error(
`Couldn't update ${this.search_ref[this.ref]} table`,
key,
encounter.name,
error,
search_entry
);
}
}
// const count_ref = db.ref(`${this.search_ref[this.ref]}/${uid}/metadata/${cid}/count`);
// await count_ref.set(Object.keys(entries).length);
const count_ref = db.ref(`${this.search_ref[this.ref]}/${uid}/metadata/${cid}/count`);
await count_ref.set(Object.keys(entries).length);
}
console.groupEnd();
} else if (this.ref === "campaigns") {
Expand Down

0 comments on commit dd27e1c

Please sign in to comment.