-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: server side search API (#2112) * refactor repository_recipes filter building * add food filter to recipe repository page_all * fix query type annotations * working search * add tests and make sure title matches are ordered correctly * remove instruction matching again * fix formatting and small issues * fix another linting error * make search test no rely on actual words * fix failing postgres compiled query * revise incorrectly ordered migration * automatically extract latest migration version * test migration orderes * run type generators * new search function * wip: new search page * sortable field options * fix virtual scroll issue * fix search casing bug * finalize search filters/sorts * remove old composable * fix type errors --------- Co-authored-by: Sören <fleshgolem@gmx.net>
- Loading branch information
1 parent
fc105dc
commit 71f8c10
Showing
36 changed files
with
1,050 additions
and
815 deletions.
There are no files selected for viewing
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
alembic/versions/2023-02-10-21.18.32_16160bf731a0_add_more_indices_necessary_for_search.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""add more indices necessary for search | ||
Revision ID: 16160bf731a0 | ||
Revises: ff5f73b01a7a | ||
Create Date: 2023-02-10 21:18:32.405130 | ||
""" | ||
import sqlalchemy as sa | ||
|
||
import mealie.db.migration_types | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "16160bf731a0" | ||
down_revision = "ff5f73b01a7a" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_index(op.f("ix_recipe_instructions_text"), "recipe_instructions", ["text"], unique=False) | ||
op.create_index(op.f("ix_recipes_description"), "recipes", ["description"], unique=False) | ||
op.create_index(op.f("ix_recipes_ingredients_note"), "recipes_ingredients", ["note"], unique=False) | ||
op.create_index( | ||
op.f("ix_recipes_ingredients_original_text"), "recipes_ingredients", ["original_text"], unique=False | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_recipes_ingredients_original_text"), table_name="recipes_ingredients") | ||
op.drop_index(op.f("ix_recipes_ingredients_note"), table_name="recipes_ingredients") | ||
op.drop_index(op.f("ix_recipes_description"), table_name="recipes") | ||
op.drop_index(op.f("ix_recipe_instructions_text"), table_name="recipe_instructions") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<div> | ||
<v-menu v-model="state.menu" offset-y bottom nudge-bottom="3" :close-on-content-click="false"> | ||
<template #activator="{ on, attrs }"> | ||
<v-badge :value="selected.length > 0" small overlap color="primary" :content="selected.length"> | ||
<v-btn small color="accent" dark v-bind="attrs" v-on="on"> | ||
<slot></slot> | ||
</v-btn> | ||
</v-badge> | ||
</template> | ||
<v-card width="400"> | ||
<v-card-text> | ||
<v-text-field v-model="state.search" class="mb-2" hide-details dense label="Search" clearable /> | ||
<v-switch | ||
v-if="requireAll != undefined" | ||
v-model="requireAllValue" | ||
dense | ||
small | ||
:label="`${requireAll ? $tc('search.has-all') : $tc('search.has-any')}`" | ||
> | ||
</v-switch> | ||
<v-card v-if="filtered.length > 0" flat outlined> | ||
<v-virtual-scroll :items="filtered" height="300" item-height="51"> | ||
<template #default="{ item }"> | ||
<v-list-item :key="item.id" dense :value="item"> | ||
<v-list-item-action> | ||
<v-checkbox v-model="selected" :value="item"></v-checkbox> | ||
</v-list-item-action> | ||
<v-list-item-content> | ||
<v-list-item-title> {{ item.name }}</v-list-item-title> | ||
</v-list-item-content> | ||
</v-list-item> | ||
<v-divider></v-divider> | ||
</template> | ||
</v-virtual-scroll> | ||
</v-card> | ||
<div v-else> | ||
<v-alert type="info" text> No results found </v-alert> | ||
</div> | ||
</v-card-text> | ||
</v-card> | ||
</v-menu> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, reactive, computed } from "@nuxtjs/composition-api"; | ||
export interface SelectableItem { | ||
id: string; | ||
name: string; | ||
} | ||
export default defineComponent({ | ||
props: { | ||
items: { | ||
type: Array as () => SelectableItem[], | ||
required: true, | ||
}, | ||
value: { | ||
type: Array as () => any[], | ||
required: true, | ||
}, | ||
requireAll: { | ||
type: Boolean, | ||
default: undefined, | ||
}, | ||
}, | ||
setup(props, context) { | ||
const state = reactive({ | ||
search: "", | ||
menu: false, | ||
}); | ||
const requireAllValue = computed({ | ||
get: () => props.requireAll, | ||
set: (value) => { | ||
context.emit("update:requireAll", value); | ||
}, | ||
}); | ||
const selected = computed({ | ||
get: () => props.value as SelectableItem[], | ||
set: (value) => { | ||
context.emit("input", value); | ||
}, | ||
}); | ||
const filtered = computed(() => { | ||
if (!state.search) { | ||
return props.items; | ||
} | ||
return props.items.filter((item) => item.name.toLowerCase().includes(state.search.toLowerCase())); | ||
}); | ||
return { | ||
requireAllValue, | ||
state, | ||
selected, | ||
filtered, | ||
}; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.