@@ -46,8 +46,7 @@ def get_connectors_state(db_session, tenant_id) -> list[ConnectorIndexingStatus]
4646 )
4747
4848 cc_pair_identifiers = [
49- ConnectorCredentialPairIdentifier (
50- connector_id = cc_pair .connector_id , credential_id = cc_pair .credential_id )
49+ ConnectorCredentialPairIdentifier (connector_id = cc_pair .connector_id , credential_id = cc_pair .credential_id )
5150 for cc_pair in cc_pairs
5251 ]
5352
@@ -68,24 +67,26 @@ def get_connectors_state(db_session, tenant_id) -> list[ConnectorIndexingStatus]
6867 db_session = db_session ,
6968 cc_pairs = cc_pair_identifiers ,
7069 )
71- cc_pair_to_document_cnt = {(connector_id , credential_id )
72- : cnt for connector_id , credential_id , cnt in document_count_info }
70+ cc_pair_to_document_cnt = {(connector_id , credential_id ): cnt for connector_id , credential_id , cnt in document_count_info }
7371
7472 group_cc_pair_relationships = get_cc_pair_groups_for_ids (
7573 db_session = db_session ,
7674 cc_pair_ids = [cc_pair .id for cc_pair in cc_pairs ],
7775 )
7876 group_cc_pair_relationships_dict : dict [int , list [int ]] = {}
7977 for relationship in group_cc_pair_relationships :
80- group_cc_pair_relationships_dict .setdefault (
81- relationship .cc_pair_id , []).append (relationship .user_group_id )
78+ group_cc_pair_relationships_dict .setdefault (relationship .cc_pair_id , []).append (relationship .user_group_id )
8279
8380 search_settings : SearchSettings | None = None
8481 if not secondary_index :
8582 search_settings = get_current_search_settings (db_session )
8683 else :
8784 search_settings = get_secondary_search_settings (db_session )
8885
86+ connector_to_cc_pair_ids : dict [int , list [int ]] = {}
87+ for cc_pair in cc_pairs :
88+ connector_to_cc_pair_ids .setdefault (cc_pair .connector_id , []).append (cc_pair .id )
89+
8990 for cc_pair in cc_pairs :
9091 # TODO remove this to enable ingestion API
9192 if cc_pair .name == "DefaultCCPair" :
@@ -100,8 +101,7 @@ def get_connectors_state(db_session, tenant_id) -> list[ConnectorIndexingStatus]
100101 in_progress = False
101102 if search_settings :
102103 redis_connector = RedisConnector (tenant_id , cc_pair .id )
103- redis_connector_index = redis_connector .new_index (
104- search_settings .id )
104+ redis_connector_index = redis_connector .new_index (search_settings .id )
105105 if redis_connector_index .fenced :
106106 in_progress = True
107107
@@ -110,8 +110,7 @@ def get_connectors_state(db_session, tenant_id) -> list[ConnectorIndexingStatus]
110110 # if r.exists(rci.fence_key):
111111 # in_progress = True
112112
113- latest_index_attempt = cc_pair_to_latest_index_attempt .get (
114- (connector .id , credential .id ))
113+ latest_index_attempt = cc_pair_to_latest_index_attempt .get ((connector .id , credential .id ))
115114
116115 latest_finished_attempt = get_latest_index_attempt_for_cc_pair_id (
117116 db_session = db_session ,
@@ -124,40 +123,36 @@ def get_connectors_state(db_session, tenant_id) -> list[ConnectorIndexingStatus]
124123 ConnectorIndexingStatus (
125124 cc_pair_id = cc_pair .id ,
126125 name = cc_pair .name ,
126+ in_progress = in_progress ,
127127 cc_pair_status = cc_pair .status ,
128- connector = ConnectorSnapshot . from_connector_db_model ( connector ) ,
129- credential = CredentialSnapshot . from_credential_db_model (
130- credential ),
128+ in_repeated_error_state = cc_pair . in_repeated_error_state ,
129+ connector = ConnectorSnapshot . from_connector_db_model ( connector , connector_to_cc_pair_ids . get ( connector . id , [])),
130+ credential = CredentialSnapshot . from_credential_db_model ( credential ),
131131 access_type = cc_pair .access_type ,
132132 owner = credential .user .email if credential .user else "" ,
133133 groups = group_cc_pair_relationships_dict .get (cc_pair .id , []),
134- last_finished_status = (
135- latest_finished_attempt .status if latest_finished_attempt else None ),
136- last_status = (
137- latest_index_attempt .status if latest_index_attempt else None ),
134+ last_finished_status = (latest_finished_attempt .status if latest_finished_attempt else None ),
135+ last_status = (latest_index_attempt .status if latest_index_attempt else None ),
138136 last_success = cc_pair .last_successful_index_time ,
139- docs_indexed = cc_pair_to_document_cnt .get (
140- (connector .id , credential .id ), 0 ),
141- error_msg = (
142- latest_index_attempt .error_msg if latest_index_attempt else None ),
137+ docs_indexed = cc_pair_to_document_cnt .get ((connector .id , credential .id ), 0 ),
138+ # error_msg=(
139+ # latest_index_attempt.error_msg if latest_index_attempt else None),
143140 latest_index_attempt = (
144- IndexAttemptSnapshot .from_index_attempt_db_model (
145- latest_index_attempt ) if latest_index_attempt else None
141+ IndexAttemptSnapshot .from_index_attempt_db_model (latest_index_attempt ) if latest_index_attempt else None
146142 ),
147- deletion_attempt = get_deletion_attempt_snapshot (
148- connector_id = connector .id ,
149- credential_id = credential .id ,
150- db_session = db_session ,
151- tenant_id = tenant_id ,
152- ),
153- is_deletable = check_deletion_attempt_is_allowed (
154- connector_credential_pair = cc_pair ,
155- db_session = db_session ,
156- # allow scheduled indexing attempts here, since on deletion request we will cancel them
157- allow_scheduled = True ,
158- )
159- is None ,
160- in_progress = in_progress ,
143+ # deletion_attempt=get_deletion_attempt_snapshot(
144+ # connector_id=connector.id,
145+ # credential_id=credential.id,
146+ # db_session=db_session,
147+ # tenant_id=tenant_id,
148+ # ),
149+ # is_deletable=check_deletion_attempt_is_allowed(
150+ # connector_credential_pair=cc_pair,
151+ # db_session=db_session,
152+ # # allow scheduled indexing attempts here, since on deletion request we will cancel them
153+ # allow_scheduled=True,
154+ # )
155+ # is None,
161156 )
162157 )
163158 return indexing_statuses
0 commit comments