Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: David Salvisberg <[email protected]>
  • Loading branch information
cyrillkuettel and Daverball authored Jul 4, 2024
1 parent 084813e commit 66f479d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
12 changes: 4 additions & 8 deletions src/privatim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,9 @@ def upgrade(context: 'UpgradeContext'): # type: ignore[no-untyped-def]
),
)

if not context.has_column(
'consultations', 'searchable_text_de_CH'
):
for column in ('searchable_text_de_CH',):
if not context.has_column('consultations', column):
context.operations.add_column(
'consultations', Column(column, TSVECTOR())
)
context.operations.add_column(
'consultations',
Column('searchable_text_de_CH', TSVECTOR())
)

context.commit()
2 changes: 1 addition & 1 deletion src/privatim/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def includeme(config: 'Configurator') -> None:


def update_fulltext_search_text(
mapper: 'Mapper[Incomplete]', connection: 'Connection', target: Incomplete
mapper: 'Mapper[SearchableAssociatedFiles]', connection: 'Connection', target: SearchableAssociatedFiles
) -> None:
"""
Event listener for the 'files' relationship. Triggers a full reindex
Expand Down
7 changes: 3 additions & 4 deletions src/privatim/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SearchCollection:
| term | tsquery |
|------|---------|
| the donkey | |'donkey' |
| the donkey | 'donkey' |
| "blue donkey" | 'blue' & 'donkey' |
See also:
Expand Down Expand Up @@ -97,7 +97,7 @@ def search_in_columns(
self, model: type['HasSearchableFields']
) -> list[SearchResult]:
query = self.build_attribute_query(model)
raw_results = self.session.execute(query).all()
raw_results = self.session.execute(query)
return [
SearchResult(
id=result.id,
Expand All @@ -116,9 +116,8 @@ def search_in_model_files(
self, model: SearchableAssociatedFiles
) -> list[SearchResult]:
query = self.build_file_query(model)
raw_results = self.session.execute(query).all()
results_list = []
for result in raw_results:
for result in self.session.execute(query):
search_result = SearchResult(
id=result.id,
headlines={
Expand Down
3 changes: 1 addition & 2 deletions src/privatim/views/templates/activities.pt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<tal:b tal:condition="show_add_button">
<div class="col-md-6 text-end">
<a i18n:translate="" href="${request.route_url('add_consultation')}"
class="btn btn-primary" role="button" tabindex="1">Add
Consultation</a>
class="btn btn-primary" role="button" tabindex="1">Add Consultation</a>
</div>
</tal:b>

Expand Down

0 comments on commit 66f479d

Please sign in to comment.