Skip to content

Commit

Permalink
adjust changelog(#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-flo committed Feb 4, 2025
1 parent b39b26a commit 5b25cbf
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ActivityDTO getActivity(String login) {
pullRequestBadPracticeRepository.findAssignedByLoginAndOpen(login);

Map<PullRequest, List<PullRequestBadPracticeDTO>> pullRequestBadPracticesMap = openPulLRequestBadPractices
.stream()
.stream().filter(pullRequestBadPractice -> !pullRequestBadPractice.isResolved())
.collect(
Collectors.groupingBy(
PullRequestBadPractice::getPullrequest,
Expand All @@ -71,7 +71,6 @@ public ActivityDTO getActivity(String login) {
return new ActivityDTO(openPullRequestsWithBadPractices);
}

@Transactional
public List<PullRequestBadPracticeDTO> detectBadPractices(String login) {
logger.info("Detecting bad practices for user with login: {}", login);

Expand All @@ -80,12 +79,14 @@ public List<PullRequestBadPracticeDTO> detectBadPractices(String login) {
Set.of(Issue.State.OPEN)
);

List<PullRequestBadPractice> existingBadPractices = pullRequestBadPracticeRepository.findAssignedByLoginAndOpen(login);
existingBadPractices.forEach(existingBadPractice -> existingBadPractice.setResolved(true));
pullRequestBadPracticeRepository.saveAll(existingBadPractices);

List<PullRequestBadPractice> detectedBadPractices = new ArrayList<>();
for (PullRequest pullRequest : pullRequests) {
detectedBadPractices.addAll(pullRequestBadPracticeDetector.detectAndSyncBadPractices(pullRequest));
}
return detectedBadPractices.stream().map(PullRequestBadPracticeDTO::fromPullRequestBadPractice).toList();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public List<PullRequestBadPractice> detectAndSyncBadPractices(PullRequest pullRe
return detectedBadPractices;
}

private PullRequestBadPractice handleDetectedBadPractices(PullRequest pullRequest, BadPractice badPractice) {
@Transactional
protected PullRequestBadPractice handleDetectedBadPractices(PullRequest pullRequest, BadPractice badPractice) {

PullRequestBadPractice pullRequestBadPractice = new PullRequestBadPractice();
pullRequestBadPractice.setTitle(badPractice.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

import de.tum.in.www1.hephaestus.gitprovider.pullrequest.PullRequest;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Setter
@NoArgsConstructor
@ToString
@Table(name="pullrequestbadpractice")
public class PullRequestBadPractice {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SELECT MIN(p.createdAt)
)
Optional<OffsetDateTime> firstContributionByAuthorLogin(@Param("authorLogin") String authorLogin);

@Transactional
@Query(
"""
SELECT p
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="iam-flo" id="1738063112622-1">
<createTable tableName="pull_request_bad_practice">
<column name="id" type="BIGINT">
<createTable tableName="pullrequestbadpractice">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pull_request_bad_practicePK"/>
</column>
<column name="description" type="VARCHAR(255)"/>
Expand All @@ -14,6 +14,6 @@
</createTable>
</changeSet>
<changeSet author="iam-flo" id="1738063112622-2">
<addForeignKeyConstraint baseColumnNames="pullrequest_id" baseTableName="pull_request_bad_practice" constraintName="FK3e8oyqf1a5g1bspal23e1r4nr" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="issue" validate="true"/>
<addForeignKeyConstraint baseColumnNames="pullrequest_id" baseTableName="pullrequestbadpractice" constraintName="FK3e8oyqf1a5g1bspal23e1r4nr" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="issue" validate="true"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ActivityDashboardComponent {
protected userLogin: string | null = null;
protected numberOfPullRequests = computed(() => this.query.data()?.pullRequests?.length ?? 0);
protected numberOfBadPractices = computed(() => this.query.data()?.pullRequests?.reduce((acc, pr) => acc + (pr.badPractices?.length ?? 0), 0) ?? 0);
protected readonly RefreshCcw = RefreshCcw;

constructor(private route: ActivatedRoute) {
this.userLogin = this.route.snapshot.paramMap.get('id');
Expand All @@ -35,5 +36,4 @@ export class ActivityDashboardComponent {
console.log('Detecting bad practices');
this.activityService.detectBadPracticesByUser(this.userLogin!).subscribe();
};
protected readonly RefreshCcw = RefreshCcw;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<brn-collapsible-content>
@for (badpractice of badPractices(); track badpractice.title) {
<brn-separator hlmSeparator />
<app-bad-practice-card [title]="badpractice.title" [description]="badpractice.description" [resolved]="false"></app-bad-practice-card>
<app-bad-practice-card [title]="badpractice.title" [description]="badpractice.description" [resolved]="badpractice.resolved"></app-bad-practice-card>
}
</brn-collapsible-content>
</div>
Expand Down

0 comments on commit 5b25cbf

Please sign in to comment.