[24.02.20] Reset replicas, changed to use LocalDateTime
This commit is contained in:
parent
1d4a0d12a7
commit
ecb4b16be7
@ -6,7 +6,7 @@ metadata:
|
|||||||
name: RESOURCE_NAME
|
name: RESOURCE_NAME
|
||||||
namespace: default
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
replicas: 2
|
replicas: 0
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: RESOURCE_NAME
|
app: RESOURCE_NAME
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package cryptosky.me.graphql.pricing.models.entities;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.Date;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ -17,7 +17,7 @@ public class CryptoPriceModel {
|
|||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Column(name = "timestamp", nullable = false)
|
@Column(name = "timestamp", nullable = false)
|
||||||
private Date timestamp;
|
private LocalDateTime timestamp;
|
||||||
|
|
||||||
@Column(name = "symbol", nullable = false)
|
@Column(name = "symbol", nullable = false)
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@ -7,15 +7,13 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import cryptosky.me.graphql.pricing.service.BtcPriceService;
|
import cryptosky.me.graphql.pricing.service.BtcPriceService;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class BtcPriceMutation implements GraphQLMutationResolver {
|
public class BtcPriceMutation implements GraphQLMutationResolver {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BtcPriceService btcPriceService;
|
private BtcPriceService btcPriceService;
|
||||||
|
|
||||||
public BtcPriceModel createBtc(final Date createdDate, final String type, final float av_price,
|
public BtcPriceModel createBtc(final String createdDate, final String type, final float av_price,
|
||||||
final float h_price, final float l_price, final float o_price,
|
final float h_price, final float l_price, final float o_price,
|
||||||
final float c_price, final float volume ) {
|
final float c_price, final float volume ) {
|
||||||
return this.btcPriceService.createBtc(createdDate, type, av_price, h_price, l_price, o_price, c_price, volume);
|
return this.btcPriceService.createBtc(createdDate, type, av_price, h_price, l_price, o_price, c_price, volume);
|
||||||
|
|||||||
@ -27,11 +27,11 @@ public class BtcPriceQuery implements GraphQLQueryResolver {
|
|||||||
return this.btcPriceService.getLatest();
|
return this.btcPriceService.getLatest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||||
// return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String endDate ) {
|
public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String endDate ) {
|
||||||
// return this.btcPriceService.getPriceBetweenDates(startDate, endDate);
|
return this.btcPriceService.getPriceBetweenDates(startDate, endDate);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,12 @@ import cryptosky.me.graphql.pricing.models.repositories.BtcPriceRepository;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cryptosky.me.helpers.Utils.format;
|
import static cryptosky.me.helpers.Utils.format;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -22,12 +23,12 @@ public class BtcPriceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public BtcPriceModel createBtc(final Date createdDate, final String type, final float av_price,
|
public BtcPriceModel createBtc(final String createdDate, final String type, final float av_price,
|
||||||
final float h_price, final float l_price, final float o_price,
|
final float h_price, final float l_price, final float o_price,
|
||||||
final float c_price, final float volume ) {
|
final float c_price, final float volume ) {
|
||||||
|
|
||||||
final BtcPriceModel btcPrice = new BtcPriceModel();
|
final BtcPriceModel btcPrice = new BtcPriceModel();
|
||||||
btcPrice.setTimestamp(createdDate);
|
btcPrice.setTimestamp(LocalDateTime.parse((createdDate)));
|
||||||
btcPrice.setType(type);
|
btcPrice.setType(type);
|
||||||
btcPrice.setAverage_price(av_price);
|
btcPrice.setAverage_price(av_price);
|
||||||
btcPrice.setHigh_price(h_price);
|
btcPrice.setHigh_price(h_price);
|
||||||
@ -59,20 +60,20 @@ public class BtcPriceService {
|
|||||||
return this.btcPriceRepository.findAll().stream().findFirst();
|
return this.btcPriceRepository.findAll().stream().findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||||
// return this.btcPriceRepository.findAll().stream()
|
return this.btcPriceRepository.findAll().stream()
|
||||||
// .filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
.filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
||||||
// .findFirst();
|
.findFirst();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
// public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
||||||
// return this.btcPriceRepository.findAll().stream()
|
return this.btcPriceRepository.findAll().stream()
|
||||||
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isBefore(format(endDate)))
|
.filter(createdDateList -> format(createdDateList.getTimestamp().toString()).isBefore(format(endDate)))
|
||||||
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isAfter(format(startDate)))
|
.filter(createdDateList -> format(createdDateList.getTimestamp().toString()).isAfter(format(startDate)))
|
||||||
// .collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @Transactional(readOnly = true)
|
// @Transactional(readOnly = true)
|
||||||
// public List<BtcPriceModel> getAllLatest() {
|
// public List<BtcPriceModel> getAllLatest() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user