Skip to content

refactor connection and move mosaic endpoints #127

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

Closed
wants to merge 1 commit into from

Conversation

vincentsarago
Copy link
Member

No description provided.

response_model_exclude_none=True,
tags=["Mosaic"],
)
def register_search(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we move the register/list endpoint outside the Factor because it now used /mosaic/{search_id} prefix

@vincentsarago
Copy link
Member Author

In theory this PR could enable #118

def CollectionIdParams(
    collection_id: Annotated[
        str,
        Path(description="Collection Id"),
    ],
    connection=Depends(db_conn),
) -> str:
    """SearchId"""
    search = model.PgSTACSearch(
        collections=[collection_id],
        filter_lang="cql-json"
    )
    metadata = model.Metadata(name=f"Mosaic for {collection_id} Collection")

    with connection.cursor(row_factory=class_row(model.Search)) as cursor:
        cursor.execute(
            "SELECT * FROM search_query(%s, _metadata => %s);",
            (
                search.model_dump_json(by_alias=True, exclude_none=True),
                metadata.model_dump_json(exclude_none=True),
            ),
        )
        search_info = cursor.fetchone()

    return search_info.id




###############################################################################
# Collection Endpoints
collections = MosaicTilerFactory(
    path_dependency=CollectionIdParams,
    optional_headers=optional_headers,
    router_prefix="/collections/{collection_id}",
    add_statistics=True,
    add_viewer=True,
    add_part=True,
)
app.include_router(collections.router, tags=["Collection"], prefix="/collections/{collection_id}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant