Merge branch 'mealie-next' into feat/switch-docker-builds-to-depot

This commit is contained in:
boc-the-git 2024-02-14 12:45:52 +11:00 committed by GitHub
commit ad251b2449
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 56 additions and 22 deletions

View File

@ -54,8 +54,8 @@ Changing the webworker settings may cause unforeseen memory leak issues with Mea
| ---------------- | :-----: | --------------------------------------------------------------------------------------------------------------------------------- | | ---------------- | :-----: | --------------------------------------------------------------------------------------------------------------------------------- |
| WEB_GUNICORN | false | Enables Gunicorn to manage Uvicorn web for multiple works | | WEB_GUNICORN | false | Enables Gunicorn to manage Uvicorn web for multiple works |
| WORKERS_PER_CORE | 1 | Set the number of workers to the number of CPU cores multiplied by this value (Value \* CPUs). More info [here][workers_per_core] | | WORKERS_PER_CORE | 1 | Set the number of workers to the number of CPU cores multiplied by this value (Value \* CPUs). More info [here][workers_per_core] |
| MAX_WORKERS | 1 | Set the maximum number of workers to use. Default is not set meaning unlimited. More info [here][max_workers] | | MAX_WORKERS | None | Set the maximum number of workers to use. Default is not set meaning unlimited. More info [here][max_workers] |
| WEB_CONCURRENCY | 1 | Override the automatic definition of number of workers. More info [here][web_concurrency] | | WEB_CONCURRENCY | 2 | Override the automatic definition of number of workers. More info [here][web_concurrency] |
### LDAP ### LDAP
@ -95,3 +95,8 @@ Setting the following environmental variables will change the theme of the front
| THEME_DARK_INFO | #1976D2 | Dark Theme Config Variable | | THEME_DARK_INFO | #1976D2 | Dark Theme Config Variable |
| THEME_DARK_WARNING | #FF6D00 | Dark Theme Config Variable | | THEME_DARK_WARNING | #FF6D00 | Dark Theme Config Variable |
| THEME_DARK_ERROR | #EF5350 | Dark Theme Config Variable | | THEME_DARK_ERROR | #EF5350 | Dark Theme Config Variable |
[workers_per_core]: https://github.com/tiangolo/uvicorn-gunicorn-docker/blob/2daa3e3873c837d5781feb4ff6a40a89f791f81b/README.md#workers_per_core
[max_workers]: https://github.com/tiangolo/uvicorn-gunicorn-docker/blob/2daa3e3873c837d5781feb4ff6a40a89f791f81b/README.md#max_workers
[web_concurrency]: https://github.com/tiangolo/uvicorn-gunicorn-docker/blob/2daa3e3873c837d5781feb4ff6a40a89f791f81b/README.md#web_concurrency

File diff suppressed because one or more lines are too long

View File

@ -19,11 +19,11 @@
</div> </div>
</v-card-text> </v-card-text>
<v-list v-if="showViewer" dense class="mt-0 pt-0"> <v-list v-if="showViewer" dense class="mt-0 pt-0">
<v-list-item v-for="(item, key, index) in labels" :key="index" style="min-height: 25px" dense> <v-list-item v-for="(item, key, index) in renderedList" :key="index" style="min-height: 25px" dense>
<v-list-item-content> <v-list-item-content>
<v-list-item-title class="pl-4 caption flex row"> <v-list-item-title class="pl-4 caption flex row">
<div>{{ item.label }}</div> <div>{{ item.label }}</div>
<div class="ml-auto mr-1">{{ value[key] }}</div> <div class="ml-auto mr-1">{{ item.value }}</div>
<div>{{ item.suffix }}</div> <div>{{ item.suffix }}</div>
</v-list-item-title> </v-list-item-title>
</v-list-item-content> </v-list-item-content>
@ -37,6 +37,14 @@
import { computed, defineComponent, useContext } from "@nuxtjs/composition-api"; import { computed, defineComponent, useContext } from "@nuxtjs/composition-api";
import { Nutrition } from "~/lib/api/types/recipe"; import { Nutrition } from "~/lib/api/types/recipe";
type NutritionLabelType = {
[key: string]: {
label: string;
suffix: string;
value?: string;
};
};
export default defineComponent({ export default defineComponent({
props: { props: {
value: { value: {
@ -50,34 +58,34 @@ export default defineComponent({
}, },
setup(props, context) { setup(props, context) {
const { i18n } = useContext(); const { i18n } = useContext();
const labels = { const labels = <NutritionLabelType>{
calories: { calories: {
label: i18n.t("recipe.calories"), label: i18n.tc("recipe.calories"),
suffix: i18n.t("recipe.calories-suffix"), suffix: i18n.tc("recipe.calories-suffix"),
}, },
fatContent: { fatContent: {
label: i18n.t("recipe.fat-content"), label: i18n.tc("recipe.fat-content"),
suffix: i18n.t("recipe.grams"), suffix: i18n.tc("recipe.grams"),
}, },
fiberContent: { fiberContent: {
label: i18n.t("recipe.fiber-content"), label: i18n.tc("recipe.fiber-content"),
suffix: i18n.t("recipe.grams"), suffix: i18n.tc("recipe.grams"),
}, },
proteinContent: { proteinContent: {
label: i18n.t("recipe.protein-content"), label: i18n.tc("recipe.protein-content"),
suffix: i18n.t("recipe.grams"), suffix: i18n.tc("recipe.grams"),
}, },
sodiumContent: { sodiumContent: {
label: i18n.t("recipe.sodium-content"), label: i18n.tc("recipe.sodium-content"),
suffix: i18n.t("recipe.milligrams"), suffix: i18n.tc("recipe.milligrams"),
}, },
sugarContent: { sugarContent: {
label: i18n.t("recipe.sugar-content"), label: i18n.tc("recipe.sugar-content"),
suffix: i18n.t("recipe.grams"), suffix: i18n.tc("recipe.grams"),
}, },
carbohydrateContent: { carbohydrateContent: {
label: i18n.t("recipe.carbohydrate-content"), label: i18n.tc("recipe.carbohydrate-content"),
suffix: i18n.t("recipe.grams"), suffix: i18n.tc("recipe.grams"),
}, },
}; };
const valueNotNull = computed(() => { const valueNotNull = computed(() => {
@ -96,11 +104,25 @@ export default defineComponent({
context.emit("input", { ...props.value, [key]: event }); context.emit("input", { ...props.value, [key]: event });
} }
// Build a new list that only contains nutritional information that has a value
const renderedList = computed(() => {
return Object.entries(labels).reduce((item: NutritionLabelType, [key, label]) => {
if (props.value[key]?.trim()) {
item[key] = {
...label,
value: props.value[key],
};
}
return item;
}, {});
});
return { return {
labels, labels,
valueNotNull, valueNotNull,
showViewer, showViewer,
updateValue, updateValue,
renderedList,
}; };
}, },
}); });

View File

@ -1,3 +1,4 @@
import os
from collections.abc import Callable from collections.abc import Callable
from pathlib import Path from pathlib import Path
from time import sleep from time import sleep
@ -87,7 +88,12 @@ def main():
if max_retry == 0: if max_retry == 0:
raise ConnectionError("Database connection failed - exiting application.") raise ConnectionError("Database connection failed - exiting application.")
alembic_cfg = Config(str(PROJECT_DIR / "alembic.ini")) alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(PROJECT_DIR / "alembic.ini"))
if not os.path.isfile(alembic_cfg_path):
raise Exception("Provided alembic config path doesn't exist")
alembic_cfg = Config(alembic_cfg_path)
if db_is_at_head(alembic_cfg): if db_is_at_head(alembic_cfg):
logger.debug("Migration not needed.") logger.debug("Migration not needed.")
else: else:

View File

@ -1,3 +1,4 @@
import os
import subprocess import subprocess
import tempfile import tempfile
from fractions import Fraction from fractions import Fraction
@ -13,7 +14,7 @@ from . import utils
from .pre_processor import pre_process_string from .pre_processor import pre_process_string
CWD = Path(__file__).parent CWD = Path(__file__).parent
MODEL_PATH = CWD / "model.crfmodel" MODEL_PATH = os.getenv("CRF_MODEL_PATH", default=CWD / "model.crfmodel")
class CRFConfidence(BaseModel): class CRFConfidence(BaseModel):