From a6bb5c8cc8cf3da58c48ad40eeb7f491c96d66a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Fri, 22 May 2020 00:39:25 +0200 Subject: [PATCH] dont send date --- src/Application.kt | 1 - src/api/model/SampleObject.kt | 2 -- src/api/route/InputServiceServer.kt | 6 +++--- test.py | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Application.kt b/src/Application.kt index 1a4f126..387512a 100644 --- a/src/Application.kt +++ b/src/Application.kt @@ -23,7 +23,6 @@ fun Application.module() { install(ContentNegotiation) { gson { setPrettyPrinting() - setDateFormat("yyyy-MM-dd HH:mm:ss") } } diff --git a/src/api/model/SampleObject.kt b/src/api/model/SampleObject.kt index bbe78a1..1152ff7 100644 --- a/src/api/model/SampleObject.kt +++ b/src/api/model/SampleObject.kt @@ -1,9 +1,7 @@ package com.kmalbz.api.model import com.google.gson.annotations.SerializedName -import java.time.LocalDate data class SampleObject( - @SerializedName("date") val date: LocalDate, @SerializedName("device_id") val device_id: String ) \ No newline at end of file diff --git a/src/api/route/InputServiceServer.kt b/src/api/route/InputServiceServer.kt index f3215bf..9e646fe 100644 --- a/src/api/route/InputServiceServer.kt +++ b/src/api/route/InputServiceServer.kt @@ -1,6 +1,5 @@ package com.kmalbz.api.route -import com.google.gson.Gson import com.google.gson.GsonBuilder import com.kmalbz.api.model.ApiObject import com.kmalbz.api.model.SampleObject @@ -33,6 +32,7 @@ import org.koin.ktor.ext.inject import java.io.File import java.io.InputStream import java.io.OutputStream +import java.time.LocalDate import java.util.* import javax.activation.MimetypesFileTypeMap @@ -65,7 +65,7 @@ class InputServiceServer { val queueName = channel.queueDeclare().queue channel.queueBind(queueName, rabbitExchangeName, "") - val gson = GsonBuilder().setDateFormat("yyyy-MM-dd").setPrettyPrinting().create() + val gson = GsonBuilder().setPrettyPrinting().create() get("/sample"){ call.respond(resultObjectService.getAllInputObjects()) @@ -100,7 +100,7 @@ class InputServiceServer { val tag = UUID.randomUUID().toString() - val currentApiObject = ApiObject(tag = tag, date = description!!.date, device_id = description!!.device_id) + val currentApiObject = ApiObject(tag = tag, date = LocalDate.now(), device_id = description!!.device_id) transaction { resultObjectService.addOne(currentApiObject) diff --git a/test.py b/test.py index dd6a4d4..b3f0a78 100644 --- a/test.py +++ b/test.py @@ -2,7 +2,6 @@ import requests import os.path import json -import datetime URL = "http://127.0.0.1:8080/sample" @@ -10,7 +9,7 @@ FILE = 'CommonStarling_102761_45.wav' files = { "file": (os.path.basename(FILE), open(FILE,'rb').read(), 'audio/wave', {'Content-length' : os.path.getsize(FILE)}), - "description" : (None, json.dumps({"date" : datetime.date.today().strftime("%Y-%m-%d"), "device_id" : "123"}), "application/json") + "description" : (None, json.dumps({"device_id" : "123"}), "application/json") } r = requests.post(URL,files=files)