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 com.red.circle.other.inner.model.dto.user.ActiveUserCountryCodeDTO;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -41,6 +43,9 @@ public class DatavRestController extends BaseController {
|
|||||||
private final CountryDashboardDailyMetricService countryDashboardDailyMetricService;
|
private final CountryDashboardDailyMetricService countryDashboardDailyMetricService;
|
||||||
private final CountryDashboardGameMetricService countryDashboardGameMetricService;
|
private final CountryDashboardGameMetricService countryDashboardGameMetricService;
|
||||||
|
|
||||||
|
@Value("${red-circle.country-dashboard.query-enabled:true}")
|
||||||
|
private boolean countryDashboardQueryEnabled;
|
||||||
|
|
||||||
@GetMapping("/active/user-country-code")
|
@GetMapping("/active/user-country-code")
|
||||||
public List<ActiveUserCountryCodeDTO> latestActiveUserCountryCode() {
|
public List<ActiveUserCountryCodeDTO> latestActiveUserCountryCode() {
|
||||||
return userExpandService.latestActiveUserCountryCode(LocalDateTime.now().minusHours(2));
|
return userExpandService.latestActiveUserCountryCode(LocalDateTime.now().minusHours(2));
|
||||||
@ -58,30 +63,45 @@ public class DatavRestController extends BaseController {
|
|||||||
|
|
||||||
@GetMapping("/country-dashboard")
|
@GetMapping("/country-dashboard")
|
||||||
public CountryDashboardCO countryDashboard(CountryDashboardQryCmd cmd) {
|
public CountryDashboardCO countryDashboard(CountryDashboardQryCmd cmd) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return emptyCountryDashboard(cmd);
|
||||||
|
}
|
||||||
return countryDashboardService.query(cmd);
|
return countryDashboardService.query(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/country-dashboard/recharge-details")
|
@GetMapping("/country-dashboard/recharge-details")
|
||||||
public PageResult<CountryDashboardRechargeDetailCO> countryDashboardRechargeDetails(
|
public PageResult<CountryDashboardRechargeDetailCO> countryDashboardRechargeDetails(
|
||||||
CountryDashboardRechargeDetailQryCmd cmd) {
|
CountryDashboardRechargeDetailQryCmd cmd) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return PageResult.newPageResult(0);
|
||||||
|
}
|
||||||
return countryDashboardService.pageRechargeDetails(cmd);
|
return countryDashboardService.pageRechargeDetails(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/country-dashboard/game-metrics")
|
@GetMapping("/country-dashboard/game-metrics")
|
||||||
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetrics(
|
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetrics(
|
||||||
CountryDashboardGameMetricQryCmd cmd) {
|
CountryDashboardGameMetricQryCmd cmd) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return PageResult.newPageResult(0);
|
||||||
|
}
|
||||||
return countryDashboardGameMetricService.pageGameMetrics(cmd);
|
return countryDashboardGameMetricService.pageGameMetrics(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/country-dashboard/game-metrics/games")
|
@GetMapping("/country-dashboard/game-metrics/games")
|
||||||
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetricGames(
|
public PageResult<CountryDashboardGameMetricCO> countryDashboardGameMetricGames(
|
||||||
CountryDashboardGameMetricQryCmd cmd) {
|
CountryDashboardGameMetricQryCmd cmd) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return PageResult.newPageResult(0);
|
||||||
|
}
|
||||||
return countryDashboardGameMetricService.pageGameSummaries(cmd);
|
return countryDashboardGameMetricService.pageGameSummaries(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/country-dashboard/game-metrics/country-rank")
|
@GetMapping("/country-dashboard/game-metrics/country-rank")
|
||||||
public List<CountryDashboardGameMetricCO> countryDashboardGameMetricCountryRanks(
|
public List<CountryDashboardGameMetricCO> countryDashboardGameMetricCountryRanks(
|
||||||
CountryDashboardGameMetricQryCmd cmd) {
|
CountryDashboardGameMetricQryCmd cmd) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
return countryDashboardGameMetricService.listGameCountryRanks(cmd);
|
return countryDashboardGameMetricService.listGameCountryRanks(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +111,9 @@ public class DatavRestController extends BaseController {
|
|||||||
@RequestParam String endDate,
|
@RequestParam String endDate,
|
||||||
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
||||||
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin);
|
||||||
|
}
|
||||||
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
||||||
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
||||||
List<String> refreshedTimezones = countryDashboardDailyMetricService.refreshRange(
|
List<String> refreshedTimezones = countryDashboardDailyMetricService.refreshRange(
|
||||||
@ -109,6 +132,9 @@ public class DatavRestController extends BaseController {
|
|||||||
@RequestParam String endDate,
|
@RequestParam String endDate,
|
||||||
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
@RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin,
|
||||||
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
@RequestParam(value = "statTimezones", required = false) String statTimezones) {
|
||||||
|
if (!countryDashboardQueryEnabled) {
|
||||||
|
return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin);
|
||||||
|
}
|
||||||
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
LocalDate parsedStartDate = LocalDate.parse(startDate);
|
||||||
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
LocalDate parsedEndDate = LocalDate.parse(endDate);
|
||||||
List<String> refreshedTimezones = countryDashboardGameMetricService.refreshRange(
|
List<String> refreshedTimezones = countryDashboardGameMetricService.refreshRange(
|
||||||
@ -121,4 +147,23 @@ public class DatavRestController extends BaseController {
|
|||||||
"statTimezones", refreshedTimezones);
|
"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