Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 171 reports #102

Merged
merged 4 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import dev.corn.cornbackend.entities.user.data.UserResponse;
import dev.corn.cornbackend.entities.user.interfaces.UserRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityTransaction;
import jakarta.persistence.Query;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -31,11 +30,13 @@
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

@Configuration
Expand Down Expand Up @@ -85,9 +86,9 @@ public void run(String... args) {

User projectOwner = drawRandom(users);
Arrays.stream(PROJECT_NAMES)
.forEach(name -> {
projectService.addNewProject(name, projectOwner);
});
.forEach(name -> {
projectService.addNewProject(name, projectOwner);
});
Project[] projects = projectRepository.findAllByOwnerOrderByName(projectOwner, Pageable.ofSize(PROJECT_NAMES.length))
.stream().toList().toArray(new Project[0]);
Project project = projects[0];
Expand All @@ -97,7 +98,7 @@ public void run(String... args) {
.forEach(user -> Arrays.stream(projects).forEach(currentProject ->
projectMemberService.addMemberToProject(user.getUsername(), currentProject.getProjectId(), projectOwner)));

List<ProjectMember> members = projectMemberRepository.findAllByProject(project, Pageable.ofSize(users.size()))
List<ProjectMember> members = projectMemberRepository.findAllByProject(project, Pageable.ofSize(users.size()))
.stream().toList();

LocalDate prevDate = LocalDate.now();
Expand All @@ -113,29 +114,34 @@ public void run(String... args) {

List<Sprint> allSprints = sprintRepository.findAll();

List<BacklogItem> backlogItems = Arrays.stream(SAMPLE_BACKLOG_ITEMS)
.map(item -> new BacklogItem(0,
item[0], item[1],
drawRandom(statusesPool),
LocalDate.now().plusDays(random.nextInt(14)),
Collections.emptyList(),
drawRandom(members),
drawRandom(allSprints),
project,
drawRandom(typesPool)
)).map(backlogItemRepository::save).toList();
List<BacklogItem> backlogItems = new ArrayList<>();

for (Sprint sprint : allSprints) {
backlogItems.addAll(IntStream.range(0, 8 + random.nextInt(8))
.mapToObj(i -> drawRandom(SAMPLE_BACKLOG_ITEMS))
.map(item -> new BacklogItem(0,
item[0], item[1],
drawRandom(statusesPool),
null,
Collections.emptyList(),
drawRandom(members),
sprint,
project,
drawRandom(typesPool)
)).map(backlogItemRepository::save).toList());
}

for (int i = 0; i < SAMPLE_BACKLOG_ITEMS.length / 4; i++) {
for (int j = 0; j < random.nextInt(4); j++) {
long backlogItemId = drawRandom(backlogItems).getBacklogItemId();
User commenter = drawRandom(users);
for(int k = 0; k < 5; k++) {
for (int k = 0; k < 5; k++) {
backlogItemCommentService.addNewComment(new BacklogItemCommentRequest(
drawRandom(SAMPLE_COMMENTS), backlogItemId
), commenter);
}
backlogItemCommentService.addNewComment(new BacklogItemCommentRequest(
LONG_STRING, backlogItemId),users.get(4));
LONG_STRING, backlogItemId), users.get(4));
}
}

Expand All @@ -151,9 +157,31 @@ public void run(String... args) {
drawRandom(typesPool)))
.forEach(backlogItemRepository::save);

int dayShift = 24;

backlogItemRepository.saveAll(backlogItems.stream()
.filter(item -> item.getSprint().isStartAfter(LocalDate.now().plusDays(dayShift)))
.peek(item -> item.setStatus(ItemStatus.TODO))
.toList()
);
backlogItemRepository.saveAll(backlogItems.stream()
.filter(item -> item.getSprint().isEndBefore(LocalDate.now().plusDays(dayShift)))
.peek(item -> {
if (random.nextDouble() < 0.53) {
item.setStatus(ItemStatus.DONE);
LocalDate start = item.getSprint().getStartDate();
LocalDate end = item.getSprint().getEndDate();
int daysBetween = (int) ChronoUnit.DAYS.between(start, end);
item.setTaskFinishDate(start.plusDays(1+random.nextInt(daysBetween-2)).minusDays(dayShift));
} else {
item.setStatus(random.nextDouble() < 0.5 ? ItemStatus.IN_PROGRESS : ItemStatus.TODO);
}
}).toList()
);

Query query = entityManager.createNativeQuery("UPDATE sprint SET " +
"end_date = end_date - INTERVAL '17 days', " +
"start_date = start_date - INTERVAL '17 days';");
"end_date = end_date - INTERVAL '"+dayShift+" days', " +
"start_date = start_date - INTERVAL '"+dayShift+" days';");
query.executeUpdate();
}

Expand All @@ -163,6 +191,10 @@ private <T> T drawRandom(List<T> list) {
return tmp.get(0);
}

private <T> T drawRandom(T[] array) {
return array[random.nextInt(array.length)];
}

private final String[][] SAMPLE_BACKLOG_ITEMS = {
{"Develop Feature X", "Implement and test the new feature X to enhance user experience."},
{"Fix Bug in Login Module", "Investigate and resolve the login module bug reported by users."},
Expand Down Expand Up @@ -304,14 +336,14 @@ private <T> T drawRandom(List<T> list) {
{"Upgrade CAPTCHA Security", "Enhance CAPTCHA security to prevent spam and abuse."},
{"Implement Continuous Integration", "Introduce continuous integration for automated code testing and deployment."},
};

private static final String LONG_STRING =
"""
aaa very long string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
hahahaha you though I was joking this string is reeeeaalllllyyyy loooooooooooooooooooooooooooooong and guess what
it ain't stopping dfsdkfbsfdkjsbdfkljdbflkjdsbflksdjbfskldjfblksdjbfklsjdbflkjsdbflkjsdbflksdbfjklsdfb
ok I'm done\n\n\n\n\n\n\nhaha just jk ok now I'm done
""";
aaa very long string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
hahahaha you though I was joking this string is reeeeaalllllyyyy loooooooooooooooooooooooooooooong and guess what
it ain't stopping dfsdkfbsfdkjsbdfkljdbflkjdsbflksdjbfskldjfblksdjbfklsjdbflkjsdbflkjsdbflksdbfjklsdfb
ok I'm done\n\n\n\n\n\n\nhaha just jk ok now I'm done
""";

private final String[] PROJECT_NAMES = {
"BlueSky Initiative",
Expand Down
20 changes: 20 additions & 0 deletions corn-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion corn-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@angular/platform-browser-dynamic": "^17.1.0",
"@angular/router": "^17.1.0",
"@angular/service-worker": "^17.1.0",
"@canvasjs/angular-charts": "^1.2.0",
"@canvasjs/charts": "^3.8.2",
"@ng-icons/akar-icons": "^26.3.0",
"@ng-icons/bootstrap-icons": "^26.5.0",
"@ng-icons/core": "^26.3.0",
Expand Down Expand Up @@ -53,4 +55,4 @@
"tailwindcss": "^3.4.1",
"typescript": "~5.3.2"
}
}
}
5 changes: 5 additions & 0 deletions corn-frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const routes: Routes = [
loadComponent: () => import("@pages/boards/board/board.component")
.then(c => c.BoardComponent)
},
{
path: BoardsPaths.REPORTS,
loadComponent: () => import("@pages/boards/reports/reports.component")
.then(c => c.ReportsComponent)
},
{
path: RouterPaths.SETTINGS_PATH,
loadComponent: () => import("@pages/boards/project-settings/project-settings.component")
Expand Down
1 change: 1 addition & 0 deletions corn-frontend/src/app/core/enum/BoardsPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum BoardsPaths {
BACKLOG="backlog",
TIMELINE="timeline",
BOARD="board",
REPORTS = "reports",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Bucket {
remainingTasks: number;
date: Date;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface SimpleSprint {
sprintId: number;
projectId: number;
sprintName: string;
sprintDescription: string;
startDate: Date;
endDate: Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface BacklogItemResponse {
status: string;
assignee: User;
itemType: string;
taskFinishDate: string;
taskFinishDate: Date;
projectId: number;
sprintId: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span>Ładowanie sprintów...</span>
} @else {
<div class="flex items-center gap-4">
<div class="flex">
<div class="flex items-center">
<button mat-icon-button color="primary" (click)="switchDisplayedSprint(false)" [disabled]="!previousSprint">
<mat-icon>navigate_before</mat-icon>
</button>
Expand Down
2 changes: 1 addition & 1 deletion corn-frontend/src/app/pages/boards/boards.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[iconName]="'akarClipboard'" [label]="'Board'">
</sidebar-button>

<sidebar-button (click)="{}" [iconName]="'octGraph'" [label]="'Reports'"
<sidebar-button (click)="navigateToReports()" [iconName]="'octGraph'" [label]="'Reports'"
[selected]="selected === 'reports'">
</sidebar-button>

Expand Down
4 changes: 4 additions & 0 deletions corn-frontend/src/app/pages/boards/boards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export class BoardsComponent implements OnInit {
this.router.navigate([`/${ RouterPaths.BOARDS_PATH }/${ BoardsPaths.BOARD }`]);
}

navigateToReports(): void {
this.router.navigate([`/${ RouterPaths.BOARDS_PATH }/${ BoardsPaths.REPORTS }`]);
}

navigateToProjectSettings(): void {
this.router.navigate([RouterPaths.BOARDS_DIRECT_PATH, RouterPaths.SETTINGS_PATH])
}
Expand Down
20 changes: 20 additions & 0 deletions corn-frontend/src/app/pages/boards/reports/reports.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="flex flex-col gap-[16px]">
@if (currentSprint === null) {
<span>Brak sprintów w projekcie</span>
} @else if(currentSprint === undefined) {
<span>Ładowanie sprintów...</span>
} @else {
<div class="flex items-center">
<button mat-icon-button color="primary" (click)="switchDisplayedSprint(false)" [disabled]="!previousSprint">
<mat-icon>navigate_before</mat-icon>
</button>
<h1 class="text-3xl">{{ currentSprint.sprintName }}</h1>
<button mat-icon-button color="primary" (click)="switchDisplayedSprint(true)" [disabled]="!nextSprint">
<mat-icon>navigate_next</mat-icon>
</button>
</div>
}
<div>
<div id="chartContainer" style="height: 470px; width: 100%; margin:auto;"></div>
</div>
</div>
Loading
Loading