Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment refactor #462

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/env/env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"WEB_API_URL": "./",
"WEB_API_ENABLED": "true",
"DUCKDB_ENABLED": "false"
"WEB_API_ENABLED": false,
"DUCKDB_ENABLED": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const getConceptsForRequest = (measurement = []) => {
timeSeries,
issues;

if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
const metadata = value?.data[CONCEPT_METADATA][0];
conceptId = metadata.CONCEPT_ID;
conceptName = metadata.CONCEPT_NAME;
Expand Down Expand Up @@ -272,7 +272,7 @@ const save = function (item) {
return;
}
let withMeasurement;
if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
withMeasurement = conceptsData.value.filter(
(value) => value.data[CONCEPT_METADATA].CDM_TABLE_NAME === "MEASUREMENT"
);
Expand Down
27 changes: 12 additions & 15 deletions src/processes/exploreReports/config/dataLoadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ export default function getFilesByView(params = null) {
networkConcept: {
loadMethod: FETCH_MULTIPLE_FILES_BY_SOURCE,
payload: {
files:
environment.DUCKDB_ENABLED === "true"
? params.files
: [{ name: CONCEPT, instanceParams: [{}] }],
files: environment.DUCKDB_ENABLED
? params.files
: [{ name: CONCEPT, instanceParams: [{}] }],
duckdb_supported: true,
},
},
Expand Down Expand Up @@ -146,13 +145,12 @@ export default function getFilesByView(params = null) {
concept: {
loadMethod: FETCH_FILES,
payload: {
files:
environment.DUCKDB_ENABLED === "true"
? params.files
: [
{ name: DOMAIN_SUMMARY, required: true },
{ name: CONCEPT, required: true },
],
files: environment.DUCKDB_ENABLED
? params.files
: [
{ name: DOMAIN_SUMMARY, required: true },
{ name: CONCEPT, required: true },
],
duckdb_supported: true,
},
},
Expand Down Expand Up @@ -244,10 +242,9 @@ export default function getFilesByView(params = null) {
sourceConceptOverlay: {
loadMethod: FETCH_MULTIPLE_FILES_BY_RELEASE,
payload: {
files:
environment.DUCKDB_ENABLED === "true"
? params.files
: [{ name: SOURCE_CONCEPT }],
files: environment.DUCKDB_ENABLED
? params.files
: [{ name: SOURCE_CONCEPT }],
duckdb_supported: true,
},
},
Expand Down
9 changes: 3 additions & 6 deletions src/processes/exploreReports/model/store/data.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ const actions = {
},

async [FETCH_FILES]({ commit, dispatch, rootState }, payload) {
const isDuckDb =
payload.duckdb_supported && environment.DUCKDB_ENABLED === "true";
const isDuckDb = payload.duckdb_supported && environment.DUCKDB_ENABLED;
const reportName = rootState.route.name;
const path = {
cdm: { cdm_source_key: rootState.route.params.cdm },
Expand Down Expand Up @@ -246,8 +245,7 @@ const actions = {
commit(SET_DATA, { data: {} });
return;
} else {
const isDuckDb =
environment.DUCKDB_ENABLED === "true" && payload.duckdb_supported;
const isDuckDb = environment.DUCKDB_ENABLED && payload.duckdb_supported;

const reportName = rootState.route.name;
const promises = payload.files.reduce((obj, file) => {
Expand Down Expand Up @@ -316,8 +314,7 @@ const actions = {
commit(SET_DATA, { data: {} });
return;
}
const isDuckDb =
payload.duckdb_supported && environment.DUCKDB_ENABLED === "true";
const isDuckDb = payload.duckdb_supported && environment.DUCKDB_ENABLED;
const reportName = rootState.route.name;
const promises = payload.files.reduce((obj, file) => {
const selectedSource = rootGetters.getSelectedSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function concept(data) {
let seasonalityScore: string | string[];
let seasonalityComment: string;

if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
if (metadata) {
conceptData = { ...data, ...metadata };
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function feasibility(data) {
const person: PersonData = data[PERSON];

let concept, conceptId;
if (environment.DUCKDB_ENABLED === "true" && data[CONCEPT_METADATA]) {
if (environment.DUCKDB_ENABLED && data[CONCEPT_METADATA]) {
concept = combineObjectsBySource(data);
conceptId = concept?.[0]?.data[CONCEPT_METADATA]?.[0]?.CONCEPT_ID;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function combineObjectsBySource(inputObject) {

export default function networkConceptDashboard(data) {
let concept: MultipleFilesRawInterface<ConceptType>[], conceptId: string;
if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
concept = combineObjectsBySource(data);
conceptId = concept[0].data[CONCEPT_METADATA]?.[0]?.CONCEPT_ID;
if (!conceptId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function networkConcept(data) {
conceptId,
numPersons,
conceptDomain;
if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
concept = combineObjectsBySource(data);
conceptName = concept[0].data[CONCEPT_METADATA]?.[0]?.CONCEPT_NAME;
conceptDomain = concept[0].data[CONCEPT_METADATA]?.[0]?.DOMAIN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function sourceConceptOverlay(data) {
let conceptName;
let conceptId;
let numPersons;
if (environment.DUCKDB_ENABLED === "true") {
if (environment.DUCKDB_ENABLED) {
parsedResponses = combineObjectsByRelease(data);
conceptName = parsedResponses[0].data[CONCEPT_METADATA][0].CONCEPT_NAME;
conceptId = parsedResponses[0].data[CONCEPT_METADATA][0].CONCEPT_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const getters = {

const actions = {
async [WEB_API_LOG_IN]({ commit, dispatch }) {
if (environment.WEB_API_ENABLED === "false") {
if (!environment.WEB_API_ENABLED) {
return;
}
try {
Expand All @@ -63,7 +63,7 @@ const actions = {
}
},
async [GET_USER]({ commit, dispatch, rootGetters }) {
if (environment.WEB_API_ENABLED === "false") return;
if (!environment.WEB_API_ENABLED) return;
const isExpired = checkExpiryDate(LocalStorageService.get(tokenKey));

if (isExpired || !LocalStorageService.get(tokenKey)) {
Expand Down Expand Up @@ -94,7 +94,7 @@ const actions = {
},
async [LOG_OUT]({ commit, dispatch, rootGetters }, payload) {
dispatch(EDIT_USER, null);
if (environment.WEB_API_ENABLED === "true") {
if (environment.WEB_API_ENABLED) {
commit(SET_AUTHENTICATED, false);
if (!checkExpiryDate(LocalStorageService.get(tokenKey))) {
await authService.token.logout(LocalStorageService.get(tokenKey));
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/bottomNav/ui/BottomNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import SvgIcon from "@jamescoyle/vue-icon";
import { mdiCog, mdiDatabase, mdiHelpCircleOutline, mdiServer } from "@mdi/js";
import { useRouter } from "vue-router";

const webApiEnabled = environment.WEB_API_ENABLED === "true";
const webApiEnabled = environment.WEB_API_ENABLED;

const store = useStore();
const router = useRouter();
Expand Down
21 changes: 10 additions & 11 deletions src/widgets/conceptSearchForm/ui/ConceptSearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const authenticated = computed(() => {
return store.getters.authenticated;
});

const webapiEnabled = environment.WEB_API_ENABLED === "true";
const webapiEnabled = environment.WEB_API_ENABLED;

function fetchVocabularies() {
store.dispatch(webApiActions.FETCH_WEBAPI_INFO).then(() => {
Expand All @@ -310,7 +310,7 @@ function fetchVocabularies() {
}

onBeforeMount((): void => {
if (environment.WEB_API_ENABLED === "true" && authenticated.value) {
if (webapiEnabled && authenticated.value) {
fetchVocabularies();
}
});
Expand Down Expand Up @@ -384,15 +384,14 @@ const saveChanges = async (item) => {
const domain = webApiKeyMap.domains[item.DOMAIN_ID];
const conceptId = item.CONCEPT_ID;

const files =
environment.DUCKDB_ENABLED === "true"
? getDuckDBTables({ domain, concept: conceptId })[domain]
: [
{
name: CONCEPT,
instanceParams: [{ domain, concept: conceptId }],
},
];
const files = environment.DUCKDB_ENABLED
? getDuckDBTables({ domain, concept: conceptId })[domain]
: [
{
name: CONCEPT,
instanceParams: [{ domain, concept: conceptId }],
},
];

await store.dispatch(FETCH_MULTIPLE_FILES_BY_SOURCE, {
files,
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/explorer/model/store/explorer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const getters = {
);
},
getFilteredReports: function (state, getters, rootState) {
const webApiEnabled = environment.WEB_API_ENABLED === "true";
const webApiEnabled = environment.WEB_API_ENABLED;
return state.reports.filter((report) => {
const folderMatch = report.folder === getters.getSelectedFolder.name;
const webApiCondition = webApiEnabled || !report.webApiRequired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
LOG_OUT,
} from "@/shared/api/webAPI/authentication/model/store/actions.type";

const webApiDisabled = environment.WEB_API_ENABLED === "false";
const webApiDisabled = !environment.WEB_API_ENABLED;

const store = useStore();

Expand Down