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