Make dateIn optional

This commit is contained in:
Douglas Barone 2020-12-23 17:36:40 -04:00
parent b69a951b05
commit 734032186c
3 changed files with 4 additions and 7 deletions

View File

@ -8,7 +8,7 @@ export async function logs(parent, { search, dateIn, dateOut, limit }) {
const logs = await prisma.log.findMany({
where: {
timestamp: {
gte: new Date(dateIn),
gte: dateIn ? new Date(dateIn) : undefined,
lte: new Date(dateOut)
}
},

View File

@ -50,7 +50,7 @@ const typeDefs = gql`
"Application Logs"
logs(
search: String = ""
dateIn: String!
dateIn: String
dateOut: String
limit: Int = 200
): [Log]!

View File

@ -92,7 +92,7 @@ import VueJsonPretty from 'vue-json-pretty'
import 'vue-json-pretty/lib/styles.css'
const LOGS_QUERY = gql`
query($search: String, $dateIn: String!, $dateOut: String, $limit: Int) {
query($search: String, $dateIn: String, $dateOut: String, $limit: Int) {
logs(search: $search, dateIn: $dateIn, dateOut: $dateOut, limit: $limit) {
id
timestamp
@ -114,7 +114,7 @@ export default {
showSuccess: true,
search: '',
dateIn: new Date(),
dateIn: null,
dateOut: null,
limit: 100,
@ -174,9 +174,6 @@ export default {
}
}
}
},
beforeMount() {
this.dateIn = subDays(new Date(), 5).toISOString().substr(0, 10)
}
}
</script>