Что-то много всего
This commit is contained in:
parent
da8c0bb706
commit
2ae8aa816c
@ -21,7 +21,7 @@ import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -81,9 +81,9 @@ public class PullRequest {
|
||||
private PullRequestStatus status;
|
||||
|
||||
@Column(name = "create_date")
|
||||
private LocalDate createDate;
|
||||
private LocalDateTime createDate;
|
||||
|
||||
@Column(name = "update_date")
|
||||
private LocalDate updateDate;
|
||||
private LocalDateTime updateDate;
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.tsc.bitbucketbot.utils.LocalDateFromEpochDeserializer;
|
||||
import com.tsc.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ -15,10 +15,10 @@ public class CommentJson {
|
||||
private UserJson author;
|
||||
private List<CommentJson> comments;
|
||||
|
||||
@JsonDeserialize(using = LocalDateFromEpochDeserializer.class)
|
||||
private LocalDate createdDate;
|
||||
@JsonDeserialize(using = LocalDateTimeFromEpochDeserializer.class)
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
@JsonDeserialize(using = LocalDateFromEpochDeserializer.class)
|
||||
private LocalDate updatedDate;
|
||||
@JsonDeserialize(using = LocalDateTimeFromEpochDeserializer.class)
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.tsc.bitbucketbot.utils.LocalDateFromEpochDeserializer;
|
||||
import com.tsc.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -19,11 +19,11 @@ public class PullRequestJson {
|
||||
private Integer version;
|
||||
private PullRequestState state;
|
||||
|
||||
@JsonDeserialize(using = LocalDateFromEpochDeserializer.class)
|
||||
private LocalDate createdDate;
|
||||
@JsonDeserialize(using = LocalDateTimeFromEpochDeserializer.class)
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
@JsonDeserialize(using = LocalDateFromEpochDeserializer.class)
|
||||
private LocalDate updatedDate;
|
||||
@JsonDeserialize(using = LocalDateTimeFromEpochDeserializer.class)
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -191,8 +191,8 @@ public class SchedulerPullRequest {
|
||||
|
||||
@NonNull
|
||||
private Optional<String> changeVersionPr(PullRequest pullRequest, PullRequest newPullRequest) {
|
||||
LocalDate oldDate = pullRequest.getUpdateDate();
|
||||
LocalDate newDate = newPullRequest.getUpdateDate();
|
||||
LocalDateTime oldDate = pullRequest.getUpdateDate();
|
||||
LocalDateTime newDate = newPullRequest.getUpdateDate();
|
||||
if (!oldDate.isEqual(newDate)) {
|
||||
return Optional.of(
|
||||
Message.updatePullRequest(
|
||||
|
@ -42,20 +42,14 @@ public class Utils {
|
||||
if (token != null) {
|
||||
urlCon.setRequestProperty("Authorization", "Bearer " + token);
|
||||
}
|
||||
BufferedReader in;
|
||||
if (urlCon.getHeaderField("Content-Encoding") != null
|
||||
&& urlCon.getHeaderField("Content-Encoding").equals("gzip")) {
|
||||
in = new BufferedReader(new InputStreamReader(new GZIPInputStream(urlCon.getInputStream())));
|
||||
} else {
|
||||
in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
|
||||
}
|
||||
try (BufferedReader in = (isGzip(urlCon)) ?
|
||||
new BufferedReader(new InputStreamReader(new GZIPInputStream(urlCon.getInputStream())))
|
||||
: new BufferedReader(new InputStreamReader(urlCon.getInputStream()));) {
|
||||
String inputLine;
|
||||
sb = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
log.trace(e.getMessage());
|
||||
}
|
||||
@ -66,7 +60,15 @@ public class Utils {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static boolean isGzip(URLConnection urlCon) {
|
||||
return urlCon.getHeaderField("Content-Encoding") != null
|
||||
&& urlCon.getHeaderField("Content-Encoding").equals("gzip");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,23 +7,22 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
@Slf4j
|
||||
public class LocalDateFromEpochDeserializer extends JsonDeserializer<LocalDate> {
|
||||
public class LocalDateTimeFromEpochDeserializer extends JsonDeserializer<LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) {
|
||||
public LocalDateTime deserialize(JsonParser jp, DeserializationContext ctxt) {
|
||||
try {
|
||||
Long time = jp.readValueAs(Long.class);
|
||||
Instant instant = Instant.ofEpochMilli(time);
|
||||
LocalDate localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
return localDate;
|
||||
return instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return LocalDate.now();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ public class Message {
|
||||
private static final UpdateDataComparator COMPARATOR = new UpdateDataComparator();
|
||||
private static final Integer PR_COUNT = 4;
|
||||
private static final String DONATION_LINK = "https://www.tinkoff.ru/sl/1T9s4esiMf";
|
||||
public static final String HELP_LINK = "https://nuzhnapomosh.ru/about/";
|
||||
|
||||
private Message() {
|
||||
throw new IllegalStateException("Утилитарный класс");
|
||||
@ -122,8 +123,9 @@ public class Message {
|
||||
}
|
||||
if (dayX()) {
|
||||
message.append(Smile.BR).append(Smile.FUN).append(" Кстати, поздравляю, сегодня день З/П").append(Smile.BR)
|
||||
.append(Smile.DANGEROUS).append("И раз такое дело, то напоминаю, что в виду независящих от разработчика условий, бот работает на платном VDS. Поэтому всячески приветствуются ")
|
||||
.append(link("донаты на оплату сервера", DONATION_LINK)).append(Smile.BR);
|
||||
.append(Smile.DANGEROUS).append("Спасибо всем, кто ").append(link("донатил", DONATION_LINK)).append(", мы оплатили хостинг до октября :)")
|
||||
.append(Smile.BR).append("Теперь стоит ").append(link("помочь", HELP_LINK)).append(" тем, кто действительно в этом нуждается))")
|
||||
.append(Smile.BR);
|
||||
}
|
||||
message
|
||||
.append(Smile.BR)
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Period;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ -33,8 +34,8 @@ public enum Smile {
|
||||
@Getter
|
||||
private String value;
|
||||
|
||||
public static Smile statusPr(LocalDate updateDate) {
|
||||
int periodDay = Period.between(updateDate, LocalDate.now()).getDays();
|
||||
public static Smile statusPr(LocalDateTime updateDate) {
|
||||
int periodDay = Period.between(updateDate.toLocalDate(), LocalDate.now()).getDays();
|
||||
if (periodDay < 5) {
|
||||
return Smile.valueOf("DAY_" + periodDay);
|
||||
} else {
|
||||
|
@ -34,4 +34,21 @@
|
||||
<dropForeignKeyConstraint baseTableName="comment_tree" constraintName="fk_child_id_from_comment_id"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="modifyDataType-date-up-pr" author="upagge">
|
||||
<modifyDataType catalogName="pg_catalog"
|
||||
columnName="create_date"
|
||||
newDataType="datetime"
|
||||
schemaName="public"
|
||||
tableName="pull_request"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="modifyDataType-date-create-pr" author="upagge">
|
||||
<modifyDataType catalogName="pg_catalog"
|
||||
columnName="update_date"
|
||||
newDataType="datetime"
|
||||
schemaName="public"
|
||||
tableName="pull_request"/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user