Skip to content

Commit

Permalink
fix(Article): AI transcript uses attachment hash as doc id
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Aug 30, 2023
1 parent e9e4614 commit eea35ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/graphql/models/AIResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export const AIReply = new GraphQLObjectType({

export const AITranscript = new GraphQLObjectType({
name: 'AITranscript',
description: 'Transcript from OCR or speech-to-text AI models.',
description:
'Transcript from OCR or speech-to-text AI models for the specified MediaEntry ID as docId.',
interfaces: [Node, AIResponse],
fields: {
...commonAiResponseFields,
Expand Down
30 changes: 29 additions & 1 deletion src/graphql/models/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import mediaManager, {
} from 'util/mediaManager';
import ArticleReplyStatusEnum from './ArticleReplyStatusEnum';
import ArticleReply from './ArticleReply';
import { AIReply } from './AIResponse';
import { AIReply, AITranscript } from './AIResponse';
import ArticleCategoryStatusEnum from './ArticleCategoryStatusEnum';
import ReplyRequestStatusEnum from './ReplyRequestStatusEnum';
import ArticleCategory from './ArticleCategory';
Expand Down Expand Up @@ -174,6 +174,34 @@ const Article = new GraphQLObjectType({
},
},

aiTranscripts: {
type: new GraphQLNonNull(
new GraphQLList(new GraphQLNonNull(AITranscript))
),
description: 'Automated transcript',
async resolve({ attachmentHash }, _, { loaders }) {
return loaders.searchResultLoader.load({
index: 'airesponses',
type: 'doc',
body: {
query: {
bool: {
must: [
{ term: { type: 'TRANSCRIPT' } },
{ term: { docId: attachmentHash } },
{ term: { status: 'SUCCESS' } },
],
},
},
sort: {
createdAt: 'desc',
},
size: 10,
},
});
},
},

articleCategories: {
type: new GraphQLList(ArticleCategory),
args: {
Expand Down

0 comments on commit eea35ab

Please sign in to comment.