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({ const logs = await prisma.log.findMany({
where: { where: {
timestamp: { timestamp: {
gte: new Date(dateIn), gte: dateIn ? new Date(dateIn) : undefined,
lte: new Date(dateOut) lte: new Date(dateOut)
} }
}, },

View File

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

View File

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