@@ -99,7 +99,8 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
9999 Terminology .specific_ds ,
100100 Terminology .datasource_ids ,
101101 children_subquery .c .other_words ,
102- func .jsonb_agg (CoreDatasource .name ).filter (CoreDatasource .id .isnot (None )).label ('datasource_names' )
102+ func .jsonb_agg (CoreDatasource .name ).filter (CoreDatasource .id .isnot (None )).label ('datasource_names' ),
103+ Terminology .enabled
103104 )
104105 .outerjoin (
105106 children_subquery ,
@@ -122,7 +123,8 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
122123 Terminology .description ,
123124 Terminology .specific_ds ,
124125 Terminology .datasource_ids ,
125- children_subquery .c .other_words
126+ children_subquery .c .other_words ,
127+ Terminology .enabled
126128 )
127129 .order_by (Terminology .create_time .desc ())
128130 )
@@ -175,7 +177,8 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
175177 Terminology .specific_ds ,
176178 Terminology .datasource_ids ,
177179 children_subquery .c .other_words ,
178- func .jsonb_agg (CoreDatasource .name ).filter (CoreDatasource .id .isnot (None )).label ('datasource_names' )
180+ func .jsonb_agg (CoreDatasource .name ).filter (CoreDatasource .id .isnot (None )).label ('datasource_names' ),
181+ Terminology .enabled
179182 )
180183 .outerjoin (
181184 children_subquery ,
@@ -197,7 +200,8 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
197200 Terminology .description ,
198201 Terminology .specific_ds ,
199202 Terminology .datasource_ids ,
200- children_subquery .c .other_words
203+ children_subquery .c .other_words ,
204+ Terminology .enabled
201205 )
202206 .order_by (Terminology .create_time .desc ())
203207 )
@@ -214,6 +218,7 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
214218 specific_ds = row .specific_ds if row .specific_ds is not None else False ,
215219 datasource_ids = row .datasource_ids if row .datasource_ids is not None else [],
216220 datasource_names = row .datasource_names if row .datasource_names is not None else [],
221+ enabled = row .enabled if row .enabled is not None else False ,
217222 ))
218223
219224 return current_page , page_size , total_count , total_pages , _list
@@ -474,11 +479,11 @@ def save_embeddings(session_maker, ids: List[int]):
474479embedding_sql = f"""
475480SELECT id, pid, word, similarity
476481FROM
477- (SELECT id, pid, word, oid, specific_ds, datasource_ids,
482+ (SELECT id, pid, word, oid, specific_ds, datasource_ids, enabled,
478483( 1 - (embedding <=> :embedding_array) ) AS similarity
479484FROM terminology AS child
480485) TEMP
481- WHERE similarity > { settings .EMBEDDING_TERMINOLOGY_SIMILARITY } AND oid = :oid
486+ WHERE similarity > { settings .EMBEDDING_TERMINOLOGY_SIMILARITY } AND oid = :oid AND enabled = true
482487AND (specific_ds = false OR specific_ds IS NULL)
483488ORDER BY similarity DESC
484489LIMIT { settings .EMBEDDING_TERMINOLOGY_TOP_COUNT }
@@ -487,11 +492,11 @@ def save_embeddings(session_maker, ids: List[int]):
487492embedding_sql_with_datasource = f"""
488493SELECT id, pid, word, similarity
489494FROM
490- (SELECT id, pid, word, oid, specific_ds, datasource_ids,
495+ (SELECT id, pid, word, oid, specific_ds, datasource_ids, enabled,
491496( 1 - (embedding <=> :embedding_array) ) AS similarity
492497FROM terminology AS child
493498) TEMP
494- WHERE similarity > { settings .EMBEDDING_TERMINOLOGY_SIMILARITY } AND oid = :oid
499+ WHERE similarity > { settings .EMBEDDING_TERMINOLOGY_SIMILARITY } AND oid = :oid AND enabled = true
495500AND (
496501 (specific_ds = false OR specific_ds IS NULL)
497502 OR
@@ -515,7 +520,7 @@ def select_terminology_by_word(session: SessionDep, word: str, oid: int, datasou
515520 Terminology .word ,
516521 )
517522 .where (
518- and_ (text (":sentence ILIKE '%' || word || '%'" ), Terminology .oid == oid )
523+ and_ (text (":sentence ILIKE '%' || word || '%'" ), Terminology .oid == oid , Terminology . enabled == True )
519524 )
520525 )
521526
0 commit comments