diff --git a/frontend/src/ProjectData.tsx b/frontend/src/ProjectData.tsx
index 64bff5ad8..c606c70d1 100644
--- a/frontend/src/ProjectData.tsx
+++ b/frontend/src/ProjectData.tsx
@@ -1,6 +1,6 @@
-import { gql } from '@apollo/client';
-import { BadSmell } from './data/BadSmell';
-import { Project } from './data/Project';
+import {gql} from '@apollo/client';
+import {BadSmell} from './data/BadSmell';
+import {Project} from './data/Project';
export const fetchProjectQuery = gql`
query getProjects {
@@ -21,6 +21,25 @@ export const fetchProjectQuery = gql`
}
}
`;
+export const fetchRecentProjectQuery = gql`
+ query getRecentProjects {
+ getRecentProjects(size: 30) {
+ projectName
+ projectUrl
+ commitHashes
+ commits {
+ analyzerStatuses {
+ analyzerName
+ commitHash
+ localDateTime
+ numberOfIssues
+ status
+ }
+ commitHash
+ }
+ }
+ }
+`;
export const fetchAvailableRefactorings = gql`
query getAvailableRefactorings {
availableRefactorings {
@@ -75,10 +94,9 @@ export function filterDuplicateBadSmells(params: BadSmell[]) {
return badSmell.snippet != null;
});
const ids = params.map((o) => o.snippet);
- const filtered = params.filter(
- ({ snippet }, index) => !ids.includes(snippet, index + 1)
+ return params.filter(
+ ({snippet}, index) => !ids.includes(snippet, index + 1)
);
- return filtered;
}
export const fetchProjectConfigQuery = gql`
diff --git a/frontend/src/component/ProjectList.tsx b/frontend/src/component/ProjectList.tsx
index 58f80fea5..0e296f046 100644
--- a/frontend/src/component/ProjectList.tsx
+++ b/frontend/src/component/ProjectList.tsx
@@ -1,22 +1,21 @@
import { useQuery } from '@apollo/client';
-import { fetchProjectQuery } from '../ProjectData';
import { Project } from '../data/Project';
import React, { useMemo } from 'react';
import ProjectTable from './ProjectTable';
import { LinearProgress } from '@mui/material';
+import { fetchRecentProjectQuery } from '../ProjectData';
export function ProjectList({ filter }: { filter: string }) {
- const { data, loading, error } = useQuery(fetchProjectQuery);
+ const { data, loading, error } = useQuery(fetchRecentProjectQuery);
const filteredProjects = useMemo(() => {
if (!data) {
return [];
}
- return data.getProjects.filter((project: Project) => {
+ return data.getRecentProjects.filter((project: Project) => {
return project.projectName.toLowerCase().match(filter.toLowerCase());
});
}, [data, filter]);
-
if (error) {
console.error(error);
}
diff --git a/frontend/src/pages/DashBoard.tsx b/frontend/src/pages/DashBoard.tsx
index 1f9962247..fd881f8ca 100644
--- a/frontend/src/pages/DashBoard.tsx
+++ b/frontend/src/pages/DashBoard.tsx
@@ -4,8 +4,6 @@ import { useNavigate } from 'react-router';
import { ProjectList } from '../component/ProjectList';
export default function DashBoard() {
- const navigate = useNavigate();
-
const [filter, setFilter] = React.useState('');
return (
@@ -22,13 +20,7 @@ export default function DashBoard() {
/>
-
+
@@ -42,3 +34,16 @@ export default function DashBoard() {
);
}
+
+function AddProjectButton() {
+ const navigate = useNavigate();
+ return (
+
+ );
+}
diff --git a/frontend/src/pages/PageLayout.tsx b/frontend/src/pages/PageLayout.tsx
index 882ab5cd1..55d093557 100644
--- a/frontend/src/pages/PageLayout.tsx
+++ b/frontend/src/pages/PageLayout.tsx
@@ -31,7 +31,7 @@ function Navigation({ links }: NavigationProps) {
{links.map((link) => (
<>
navigate(link.href, { replace: true })}
>
diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/converter/ProjectDaoConverter.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/converter/ProjectDaoConverter.java
index 3435b84a4..a6ee8dbbc 100644
--- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/converter/ProjectDaoConverter.java
+++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/converter/ProjectDaoConverter.java
@@ -22,6 +22,11 @@ public ProjectDao convertToDao(RemoteProject entity) {
.flatMap(List::stream)
.toList();
dao.setCommits(list);
+ list.stream()
+ .reduce(
+ (first, second) -> first.localDateTime.isAfter(second.localDateTime) ? first : second)
+ .map(v -> v.localDateTime)
+ .ifPresent(dao::setLatestRun);
return dao;
}
diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/dao/ProjectDao.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/dao/ProjectDao.java
index e9c991b91..da390703d 100644
--- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/dao/ProjectDao.java
+++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/dao/ProjectDao.java
@@ -3,6 +3,7 @@
import io.quarkus.hibernate.orm.panache.PanacheEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToMany;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -12,6 +13,7 @@ public class ProjectDao extends PanacheEntity {
private String projectName;
private String projectUrl;
+ private LocalDateTime latestRun;
@OneToMany private List commits = new ArrayList<>();
@@ -61,4 +63,15 @@ public List getCommits() {
public void setCommits(List commits) {
this.commits = commits;
}
+
+ public LocalDateTime getLatestRun() {
+ if (null == latestRun) {
+ latestRun = LocalDateTime.MIN;
+ }
+ return latestRun;
+ }
+
+ public void setLatestRun(LocalDateTime localDateTime) {
+ latestRun = localDateTime;
+ }
}
diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepository.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepository.java
index 3c95eaf8c..38597851b 100644
--- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepository.java
+++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepository.java
@@ -5,6 +5,7 @@
import io.github.martinwitt.laughing_train.persistence.dao.ProjectDao;
import io.github.martinwitt.laughing_train.persistence.repository.ProjectRepository;
import io.quarkus.hibernate.orm.panache.PanacheRepository;
+import io.quarkus.panache.common.Sort;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.transaction.Transactional;
import java.util.List;
@@ -92,6 +93,8 @@ public RemoteProject save(RemoteProject project) {
@Override
public List getRecent(int size) {
- return findAll().page(0, size).stream().map(projectDaoConverter::convertToEntity).toList();
+ return findAll(Sort.by("latestRun").descending()).page(0, size).stream()
+ .map(projectDaoConverter::convertToEntity)
+ .toList();
}
}
diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java
index 74531beda..610ad5309 100644
--- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java
+++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java
@@ -24,4 +24,13 @@ void insertProject() {
sqlProjectRepository.findByProjectName(remoteProject.getProjectName());
assertThat(byProjectName).isNotEmpty();
}
+
+ @Test
+ void getRecent() {
+ RemoteProject remoteProject = Instancio.create(RemoteProject.class);
+ sqlProjectRepository.save(remoteProject);
+ assertThat(sqlProjectRepository.getRecent(1)).isNotEmpty();
+ List recent = sqlProjectRepository.getRecent(1);
+ assertThat(recent).isNotEmpty();
+ }
}