fix: disable country dashboard queries by config
This commit is contained in:
parent
2ec48cab6b
commit
4627d2c254
@ -16,10 +16,12 @@ import com.red.circle.other.inner.model.cmd.user.OnlineCountQryCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.ActiveUserCountryCodeDTO;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -40,6 +42,9 @@ public class DatavRestController extends BaseController {
|
||||
private final CountryDashboardService countryDashboardService;
|
||||
private final CountryDashboardDailyMetricService countryDashboardDailyMetricService;
|
||||
private final CountryDashboardGameMetricService countryDashboardGameMetricService;
|
||||
|
||||
@Value("${red-circle.country-dashboard.query-enabled:true}")
|
||||
private boolean countryDashboardQueryEnabled;
|
||||
|
||||
@GetMapping("/active/user-country-code")
|
||||
public List<ActiveUserCountryCodeDTO> latestActiveUserCountryCode() {
|
||||
@ -58,30 +63,45 @@ public class DatavRestController extends BaseController {
|
||||
|
||||
@GetMapping("/country-dashboard")
|
||||
public CountryDashboardCO countryDashboard(CountryDashboardQryCmd cmd) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return emptyCountryDashboard(cmd);
|
||||
}
|
||||
return countryDashboardService.query(cmd);
|
||||
}
|
||||
|
||||
@GetMapping("/country-dashboard/recharge-details")
|
||||
public PageResult<CountryDashboardRechargeDetailCO> countryDashboardRechargeDetails(
|
||||
CountryDashboardRechargeDetailQryCmd cmd) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
return countryDashboardService.pageRechargeDetails(cmd);
|
||||
}
|
||||
|
||||
@GetMapping("/country-dashboard/game-metrics")
|
||||
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetrics(
|
||||
CountryDashboardGameMetricQryCmd cmd) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
return countryDashboardGameMetricService.pageGameMetrics(cmd);
|
||||
}
|
||||
|
||||
@GetMapping("/country-dashboard/game-metrics/games")
|
||||
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetricGames(
|
||||
CountryDashboardGameMetricQryCmd cmd) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return PageResult.newPageResult(0);
|
||||
}
|
||||
return countryDashboardGameMetricService.pageGameSummaries(cmd);
|
||||
}
|
||||
|
||||
@GetMapping("/country-dashboard/game-metrics/country-rank")
|
||||
public List<CountryDashboardGameMetricCO> countryDashboardGameMetricCountryRanks(
|
||||
CountryDashboardGameMetricQryCmd cmd) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return countryDashboardGameMetricService.listGameCountryRanks(cmd);
|
||||
}
|
||||
|
||||
@ -91,6 +111,9 @@ public class DatavRestController extends BaseController {
|
||||
@RequestParam String endDate,
|
||||
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
||||
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin);
|
||||
}
|
||||
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
||||
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
||||
List<String> refreshedTimezones = countryDashboardDailyMetricService.refreshRange(
|
||||
@ -109,6 +132,9 @@ public class DatavRestController extends BaseController {
|
||||
@RequestParam String endDate,
|
||||
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
||||
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
||||
if (!countryDashboardQueryEnabled) {
|
||||
return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin);
|
||||
}
|
||||
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
||||
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
||||
List<String> refreshedTimezones = countryDashboardGameMetricService.refreshRange(
|
||||
@ -121,4 +147,23 @@ public class DatavRestController extends BaseController {
|
||||
"statTimezones", refreshedTimezones);
|
||||
}
|
||||
|
||||
private CountryDashboardCO emptyCountryDashboard(CountryDashboardQryCmd cmd) {
|
||||
return new CountryDashboardCO()
|
||||
.setPeriodType(cmd.getPeriodType())
|
||||
.setStartDate(cmd.getStartDate())
|
||||
.setEndDate(cmd.getEndDate())
|
||||
.setStatTimezone(cmd.getStatTimezone())
|
||||
.setTotal(new com.red.circle.console.app.dto.clientobject.datav.CountryDashboardMetricCO())
|
||||
.setRecords(Collections.emptyList());
|
||||
}
|
||||
|
||||
private Map<String, Object> disabledCountryDashboardBackfill(String startDate, String endDate,
|
||||
String sysOrigin) {
|
||||
return Map.of(
|
||||
"status", "disabled",
|
||||
"startDate", startDate,
|
||||
"endDate", endDate,
|
||||
"sysOrigin", sysOrigin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user