Skip to content

Commit

Permalink
Compatible with the situation where there is no user information. (#1792
Browse files Browse the repository at this point in the history
)

Co-authored-by: jyong <[email protected]>
  • Loading branch information
JohnJyong and JohnJyong authored Dec 19, 2023
1 parent 10fc44e commit 185c2f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/fields/conversation_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def format(self, value):
}

annotation_hit_history_fields = {
'annotation_id': fields.String,
'annotation_create_account': fields.Nested(account_fields, allow_null=True)
'annotation_id': fields.String(attribute='id'),
'annotation_create_account': fields.Nested(account_fields, allow_null=True),
'created_at': TimestampField
}

message_file_fields = {
Expand Down
11 changes: 10 additions & 1 deletion api/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ def annotation(self):
def annotation_hit_history(self):
annotation_history = (db.session.query(AppAnnotationHitHistory)
.filter(AppAnnotationHitHistory.message_id == self.id).first())
return annotation_history
if annotation_history:
annotation = (db.session.query(MessageAnnotation).
filter(MessageAnnotation.id == annotation_history.annotation_id).first())
return annotation
return None

@property
def app_model_config(self):
Expand Down Expand Up @@ -659,6 +663,11 @@ def account(self):
account = db.session.query(Account).filter(Account.id == self.account_id).first()
return account

@property
def annotation_create_account(self):
account = db.session.query(Account).filter(Account.id == self.account_id).first()
return account


class AppAnnotationHitHistory(db.Model):
__tablename__ = 'app_annotation_hit_histories'
Expand Down

0 comments on commit 185c2f8

Please sign in to comment.