Небольшие доработки и описание пр
This commit is contained in:
parent
c70977167a
commit
3a09de1b04
@ -59,6 +59,9 @@ public class PullRequest {
|
||||
@Column(name = "version")
|
||||
private Integer version;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "author_login")
|
||||
private User author;
|
||||
|
@ -36,11 +36,9 @@ public class Utils {
|
||||
@NonNull
|
||||
public static <T> Optional<T> urlToJson(String urlValue, String token, Class<T> classOfT) {
|
||||
StringBuilder sb = null;
|
||||
URL url;
|
||||
URLConnection urlCon;
|
||||
try {
|
||||
url = new URL(urlValue);
|
||||
urlCon = url.openConnection();
|
||||
urlCon = new URL(urlValue).openConnection();
|
||||
if (token != null) {
|
||||
urlCon.setRequestProperty("Authorization", "Bearer " + token);
|
||||
}
|
||||
@ -49,7 +47,6 @@ public class Utils {
|
||||
&& urlCon.getHeaderField("Content-Encoding").equals("gzip")) {
|
||||
in = new BufferedReader(new InputStreamReader(new GZIPInputStream(urlCon.getInputStream())));
|
||||
} else {
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
|
||||
}
|
||||
String inputLine;
|
||||
@ -60,7 +57,7 @@ public class Utils {
|
||||
}
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
if (sb != null) {
|
||||
try {
|
||||
|
@ -37,6 +37,7 @@ public class PullRequestJsonConverter implements Converter<PullRequestJson, Pull
|
||||
.version(json.getVersion())
|
||||
.createDate(json.getCreatedDate())
|
||||
.updateDate(json.getUpdatedDate())
|
||||
.description(convertDescription(json.getDescription()))
|
||||
.repositoryId(json.getFromRef().getRepository().getId())
|
||||
.author(this.convertUser(json.getAuthor().getUser()))
|
||||
.name(json.getTitle())
|
||||
@ -48,6 +49,13 @@ public class PullRequestJsonConverter implements Converter<PullRequestJson, Pull
|
||||
.build();
|
||||
}
|
||||
|
||||
private String convertDescription(String description) {
|
||||
if (description != null) {
|
||||
return description.length() > 180 ? description.substring(0, 180) + "..." : description;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private User convertUser(UserJson userJson) {
|
||||
return userService.getByLogin(userJson.getName()).orElse(userJsonConverter.convert(userJson));
|
||||
}
|
||||
|
@ -31,11 +31,14 @@ public class Message {
|
||||
|
||||
@NonNull
|
||||
public static String newPullRequest(PullRequest pullRequest) {
|
||||
return Smile.FUN + " *Новый Pull Request*" + Smile.BR +
|
||||
String message = Smile.FUN + " *Новый Pull Request*" + Smile.BR +
|
||||
link(pullRequest.getName(), pullRequest.getUrl()) +
|
||||
Smile.HR +
|
||||
Smile.AUTHOR + ": " + pullRequest.getAuthor().getLogin() +
|
||||
Smile.TWO_BR;
|
||||
Smile.HR;
|
||||
if (pullRequest.getDescription() != null && !"".equals(pullRequest.getDescription())) {
|
||||
message += pullRequest.getDescription() + Smile.HR;
|
||||
}
|
||||
message += Smile.AUTHOR + ": " + pullRequest.getAuthor().getLogin() + Smile.TWO_BR;
|
||||
return message;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -109,7 +112,6 @@ public class Message {
|
||||
.limit(PR_COUNT)
|
||||
.collect(Collectors.toList());
|
||||
oldPr.forEach(pullRequest -> message.append(topPr(pullRequest)));
|
||||
message.append(Smile.BR);
|
||||
} else {
|
||||
message.append("Ты либо самый лучший работник, либо тебе не доверяют проверку ПР ").append(Smile.MEGA_FUN).append(Smile.TWO_BR)
|
||||
.append("Поздравляю, у тебя ни одного ПР на проверку!").append(Smile.BR);
|
||||
|
@ -25,4 +25,10 @@
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="v1.3.0-add-pr-description" author="upagge">
|
||||
<addColumn tableName="pull_request" schemaName="public" catalogName="pg_catalog">
|
||||
<column name="description" type="varchar(200)"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user