From 87ffb1e2e3106d6448f8bf3b030608b33ab98970 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Mon, 27 Nov 2023 23:12:43 +0100 Subject: [PATCH] feat: only show recent runs in landing page --- frontend/package.json | 3 ++- frontend/src/ProjectData.tsx | 2 +- .../api/graphql/endpoints/ProjectGraphQL.java | 6 ++++++ .../persistence/impl/SqlProjectRepository.java | 5 +++++ .../persistence/repository/ProjectRepository.java | 2 ++ github-bot/src/main/resources/application.properties | 4 +++- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index c6c8bf0fe..6348e5139 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -39,8 +39,9 @@ "scripts": { "start": "vite", "build": "tsc && vite build", - "dev": "vite preview", + "dev": "vite", "prettier": "prettier --write \"src/**/*.tsx\"" + }, "eslintConfig": { "extends": [ diff --git a/frontend/src/ProjectData.tsx b/frontend/src/ProjectData.tsx index cb146e85e..64bff5ad8 100644 --- a/frontend/src/ProjectData.tsx +++ b/frontend/src/ProjectData.tsx @@ -4,7 +4,7 @@ import { Project } from './data/Project'; export const fetchProjectQuery = gql` query getProjects { - getProjects { + getRecentProjects(size: 30) { projectName projectUrl commitHashes diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/api/graphql/endpoints/ProjectGraphQL.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/api/graphql/endpoints/ProjectGraphQL.java index 94022df54..f5b303af6 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/api/graphql/endpoints/ProjectGraphQL.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/api/graphql/endpoints/ProjectGraphQL.java @@ -32,6 +32,12 @@ public List getAllProjects() { return projectRepository.getAll().stream().map(this::mapToDto).toList(); } + @Query("getRecentProjects") + @Description("Gets all projects from the database with a limit") + public List getRecentProjects(int size) { + return projectRepository.getRecent(size).stream().map(this::mapToDto).toList(); + } + @Query("getProjectWithName") @Description("Gets project with given name from the database") public ProjectGraphQLDto getProject(String projectName) { 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 fb11e9275..3c95eaf8c 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 @@ -89,4 +89,9 @@ public RemoteProject save(RemoteProject project) { } return project; } + + @Override + public List getRecent(int size) { + return findAll().page(0, size).stream().map(projectDaoConverter::convertToEntity).toList(); + } } diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/repository/ProjectRepository.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/repository/ProjectRepository.java index 8cae1f4a4..61f00533e 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/repository/ProjectRepository.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/persistence/repository/ProjectRepository.java @@ -7,6 +7,8 @@ public interface ProjectRepository { List getAll(); + List getRecent(int size); + List findByProjectName(String projectName); boolean existsByProjectName(String projectName); diff --git a/github-bot/src/main/resources/application.properties b/github-bot/src/main/resources/application.properties index 6c8a9e9ec..87068ab81 100644 --- a/github-bot/src/main/resources/application.properties +++ b/github-bot/src/main/resources/application.properties @@ -1,4 +1,5 @@ quarkus.quinoa.ui-dir=../frontend/ +%dev.quarkus.quinoa.enabled=false quarkus.quinoa.enable-spa-routing=true %prod.quarkus.quinoa.package-manager-install=true %prod.quarkus.quinoa.package-manager-install.node-version=18.9.0 @@ -56,4 +57,5 @@ quarkus.http.cors.origins=* quarkus.vertx.max-worker-execute-time=30m %test.quarkus.scheduler.enabled=false quarkus.datasource.db-kind = mariadb -quarkus.hibernate-orm.database.generation = update \ No newline at end of file +quarkus.hibernate-orm.database.generation = update +%dev.quarkus.quinoa=false \ No newline at end of file