diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/mapper/StoreMapper.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/mapper/StoreMapper.kt index fc07f881..32a939f8 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/mapper/StoreMapper.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/mapper/StoreMapper.kt @@ -50,6 +50,30 @@ object StoreMapper { minimumOrderAmount = minimumOrderAmount, ) + fun Store.toStoreInfo(distance: Double): StoreInfo = + StoreInfo( + id = id ?: "unknown", + name = name ?: "unknown", + imageMain = imageMain ?: "unknown", + rating = roundedRating(rating), // null이면 0.0 반환 + reviewCount = reviewCount ?: 0, + deliveryTime = distance.calculateDeliveryTime().toString(), + deliveryDistance = distance, + freeDelivery = true, + address = address ?: "unknown", + latitude = latitude ?: 0.0, + longitude = longitude ?: 0.0, + phone = tel ?: "unknown", + minimumOrderAmount = minimumOrderAmount, + ) + + private fun roundedRating(rating: Float?): Double { + val rawRating = rating?.toDouble() ?: 0.0 + // 소수점 한 자리까지 반올림 + val roundedRating = Math.round(rawRating * 10) / 10.0 + return roundedRating + } + private fun Menu.toMenuResponse(): MenuOptionInfo { return MenuOptionInfo( id = this.id ?: "unknown", diff --git a/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/service/StoreService.kt b/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/service/StoreService.kt index 2f92c88f..de57cb47 100644 --- a/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/service/StoreService.kt +++ b/application-client/src/main/kotlin/org/fastcampus/applicationclient/store/service/StoreService.kt @@ -44,12 +44,8 @@ class StoreService( @StoreMetered fun getStoreInfo(storeId: String, userLat: Double, userLng: Double): StoreInfo { val findStoreNearByAndCondition = storeRepository.findStoreNearByAndCondition(storeId, userLat, userLng) - val countReviewCountByStoreId = reviewRepository.countReviewCountByStoreId(storeId) - val totalAverageScoreByStoreId = reviewRepository.getTotalAverageScoreByStoreId(storeId) return findStoreNearByAndCondition.store.toStoreInfo( findStoreNearByAndCondition.distance.toDoubleOrNull() ?: 0.0, - rating = totalAverageScoreByStoreId, - reviewCount = countReviewCountByStoreId.toInt(), ) } @@ -207,9 +203,7 @@ class StoreService( // 3) 결과를 StoreInfo로 변환 val content = storeList.map { val dist = it.distance.toDoubleOrNull() ?: 0.0 - val rating = reviewRepository.getTotalAverageScoreByStoreId(it.store.id ?: "") - val reviewCount = reviewRepository.countReviewCountByStoreId(it.store.id ?: "").toInt() - it.store.toStoreInfo(dist, rating, reviewCount) + it.store.toStoreInfo(dist) } return CursorDTOString( diff --git a/grafana/provisioning/dashboards/docker-app-client-dashboard.json b/grafana/provisioning/dashboards/docker-app-client-dashboard.json new file mode 100644 index 00000000..604c3bda --- /dev/null +++ b/grafana/provisioning/dashboards/docker-app-client-dashboard.json @@ -0,0 +1,379 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 6, + "links": [], + "panels": [ + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "11.5.1", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "direction": "backward", + "editorMode": "code", + "expr": "rate({job=\"app-client\", host!=\"\"}[1m])", + "queryType": "range", + "refId": "A" + } + ], + "title": "Docker App Client Log Status", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [] + }, + "overrides": [] + }, + "gridPos": { + "h": 17, + "w": 11, + "x": 0, + "y": 11 + }, + "id": 2, + "options": { + "displayLabels": [ + "percent" + ], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "11.5.1", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by (host) (count_over_time({ filename=\"/var/log/application-client.log\", host!=\"\"} [1m]))", + "queryType": "range", + "refId": "A" + } + ], + "title": "Request Log Records of HOST Server Pie Chart", + "type": "piechart" + }, + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 17, + "w": 13, + "x": 11, + "y": 11 + }, + "id": 4, + "options": { + "basemap": { + "config": {}, + "name": "Layer 0", + "type": "default" + }, + "controls": { + "mouseWheelZoom": true, + "showAttribution": true, + "showDebug": false, + "showMeasure": false, + "showScale": false, + "showZoom": true + }, + "layers": [ + { + "config": { + "showLegend": true, + "style": { + "color": { + "fixed": "dark-green" + }, + "opacity": 0.6, + "rotation": { + "fixed": 0, + "max": 360, + "min": -360, + "mode": "mod" + }, + "size": { + "fixed": 5, + "max": 15, + "min": 2 + }, + "symbol": { + "fixed": "img/icons/marker/circle.svg", + "mode": "fixed" + }, + "symbolAlign": { + "horizontal": "center", + "vertical": "center" + }, + "textConfig": { + "fontSize": 12, + "offsetX": 0, + "offsetY": 0, + "textAlign": "center", + "textBaseline": "middle" + } + } + }, + "filterData": { + "id": "byRefId", + "options": "A" + }, + "location": { + "latitude": "latitude", + "longitude": "longitude", + "mode": "coords" + }, + "name": "Location", + "tooltip": true, + "type": "markers" + } + ], + "tooltip": { + "mode": "details" + }, + "view": { + "allLayers": true, + "id": "coords", + "lat": 36.678484, + "lon": 126.722978, + "zoom": 6.65 + } + }, + "pluginVersion": "11.5.1", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "deenixjpgufwge" + }, + "direction": "backward", + "editorMode": "builder", + "expr": "{filename=\"/var/log/access.log\"}", + "legendFormat": "", + "queryType": "range", + "refId": "A" + } + ], + "title": "Use Docker App Client Location", + "transformations": [ + { + "id": "extractFields", + "options": { + "delimiter": ",", + "format": "json", + "jsonPaths": [ + { + "path": "latitude" + }, + { + "path": "longitude" + } + ], + "keepTime": false, + "replace": false, + "source": "Line" + } + }, + { + "id": "convertFieldType", + "options": { + "conversions": [ + { + "destinationType": "number", + "targetField": "latitude" + }, + { + "destinationType": "number", + "targetField": "longitude" + } + ], + "fields": {} + } + } + ], + "type": "geomap" + } + ], + "preload": false, + "refresh": "auto", + "schemaVersion": 40, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Docker App Client Log", + "uid": "deenjmwtb4hdse", + "version": 44, + "weekStart": "" +} \ No newline at end of file