Skip to content

Commit

Permalink
Clean up & first implementation running with OpenAI
Browse files Browse the repository at this point in the history
  • Loading branch information
mallocator committed Dec 5, 2023
1 parent 717b5b6 commit 7b3a556
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ const Query = {
},
history: (parent, args, context) => {
context.api.log.trace('GraphQL Received Request for History', args)
if (!args.target) return context.api.comms.history.all()
const sourceHistory = context.api.comms.history.bySource(args.source)
const targetHistory = context.api.comms.history.byTarget(args.target)
return [...sourceHistory, ...targetHistory]
let messages
if (!args.source && !args.target) {
messages = context.api.comms.history.all()
} else {
const sourceHistory = context.api.comms.history.bySource(args.source)
const targetHistory = context.api.comms.history.byTarget(args.target)
messages = [...sourceHistory, ...targetHistory]
}
return messages
.sort((a, b) => a.timestamp - b.timestamp)
.map((msg) => msg.toObject())
}
Expand Down

0 comments on commit 7b3a556

Please sign in to comment.