Skip to content

Commit

Permalink
fix search url
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Dec 15, 2024
1 parent 510a9f5 commit 4331489
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions papermerge/search/cli/index_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
@app.command(name="apply")
def apply_cmd(dry_run: bool = False):
"""Apply schema fields"""
SEARCH_URL = os.environ.get("PAPERMERGE__SEARCH__URL")
if not SEARCH_URL:
raise ValueError("missing PAPERMERGE__SEARCH__URL")

engine = create_engine(SEARCH_URL)
schema_manager = SchemaManager(engine, model=SearchIndex)
schema_manager = get_schema_manager()

if dry_run:
print_json(data=schema_manager.apply_dict_dump())
Expand All @@ -28,12 +23,7 @@ def apply_cmd(dry_run: bool = False):
@app.command(name="delete")
def delete_cmd(dry_run: bool = False):
"""Delete schema fields"""
SEARCH_URL = os.environ.get("PAPERMERGE__SEARCH__URL")
if not SEARCH_URL:
raise ValueError("missing PAPERMERGE__SEARCH__URL")

engine = create_engine(SEARCH_URL)
schema_manager = SchemaManager(engine, model=SearchIndex)
schema_manager = get_schema_manager()

if dry_run:
print_json(data=schema_manager.delete_dict_dump())
Expand All @@ -44,14 +34,18 @@ def delete_cmd(dry_run: bool = False):
@app.command(name="create")
def create_cmd(dry_run: bool = False):
"""Create schema fields"""
SEARCH_URL = os.environ.get("PAPERMERGE__SEARCH__URL")
if not SEARCH_URL:
raise ValueError("missing PAPERMERGE__SEARCH__URL")

engine = create_engine(SEARCH_URL)
schema_manager = SchemaManager(engine, model=SearchIndex)
schema_manager = get_schema_manager()

if dry_run:
print_json(data=schema_manager.create_dict_dump())
else:
schema_manager.create()


def get_schema_manager():
search_url = os.environ.get("PAPERMERGE__SEARCH__URL")
if not search_url:
raise ValueError("missing PAPERMERGE__SEARCH__URL")

engine = create_engine(search_url)
return SchemaManager(engine, model=SearchIndex)

0 comments on commit 4331489

Please sign in to comment.