Skip to content

Commit

Permalink
Merge branch 'develop' into feature/exam/results-page-grade-display
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Aug 14, 2024
2 parents da8555b + 1a6169f commit 7de8ab5
Show file tree
Hide file tree
Showing 544 changed files with 15,103 additions and 7,231 deletions.
98 changes: 62 additions & 36 deletions .github/workflows/analysis-of-endpoint-connections.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
# As this GitHub Workflow currently fails for many valid pull requests, it is currently disabled.

#name: Analysis-of-Endpoint-Connections
#
#on:
# pull_request:
# types:
# - opened
# - synchronize
# paths:
# - 'src/main/java/**'
# - 'src/main/webapp/**'
#
#jobs:
# analysis-of-endpoint-connections:
# timeout-minutes: 10
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Get list of modified files
# run: |
# git diff --name-only origin/${{ github.event.pull_request.base.ref }} HEAD > modified_files.txt
#
# - name: Set up JDK 21
# uses: actions/setup-java@v2
# with:
# java-version: '21'
# distribution: 'adopt'
#
# - name: Run analysis-of-endpoint-connections
# run: |
# ./gradlew :supporting_scripts:analysis-of-endpoint-connections:run --args="$(cat modified_files.txt)"
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
paths:
- 'src/main/java/**'
- 'src/main/webapp/**'

# Keep in sync with build.yml and test.yml and codeql-analysis.yml
env:
CI: true
node: 20
java: 21

jobs:
analysis-of-endpoint-connections:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get list of modified files
run: |
git diff --name-only origin/${{ github.event.pull_request.base.ref }} HEAD > modified_files.txt
# Analyze the client sided REST-API calls
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '${{ env.node }}'

- name: Install and compile TypeScript
run: |
cd supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/
npm install
tsc -p tsconfig.analysisOfEndpointConnections.json
- name: Run analysis-of-endpoint-connections-client
run: |
node supporting_scripts/analysis-of-endpoint-connections/src/main/typeScript/AnalysisOfEndpointConnectionsClient.js
- name: Upload JSON file
uses: actions/upload-artifact@v4
with:
name: rest-calls-json
path: supporting_scripts/analysis-of-endpoint-connections/restCalls.json

# Analyze the server sided endpoints
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '${{ env.java }}'

- name: Run analysis-of-endpoint-connections
run: |
./gradlew :supporting_scripts:analysis-of-endpoint-connections:run --args="$(cat modified_files.txt)"
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ on:
types:
- created

# Keep in sync with codeql-analysis.yml and test.yml
# Keep in sync with codeql-analysis.yml and test.yml and analysis-of-endpoint-connections.yml
env:
CI: true
node: 20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
schedule:
- cron: '0 16 * * 0'

# Keep in sync with build.yml and test.yml
# Keep in sync with build.yml and test.yml and analysis-of-endpoint-connections.yml
env:
CI: true
node: 20
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Refer to [Using JHipster in production](http://www.jhipster.tech/production) for
The following command can automate the deployment to a server. The example shows the deployment to the main Artemis test server (which runs a virtual machine):

```shell
./artemis-server-cli deploy [email protected] -w build/libs/Artemis-7.5.0.war
./artemis-server-cli deploy [email protected] -w build/libs/Artemis-7.5.1.war
```

## Architecture
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
}

group = "de.tum.in.www1.artemis"
version = "7.5.0"
version = "7.5.1"
description = "Interactive Learning with Individual Feedback"

java {
Expand Down Expand Up @@ -322,7 +322,7 @@ dependencies {
implementation "com.github.docker-java:docker-java-transport-httpclient5:${docker_java_version}"

// use newest version of commons-compress to avoid security issues through outdated dependencies
implementation "org.apache.commons:commons-compress:1.26.2"
implementation "org.apache.commons:commons-compress:1.27.0"


// import JHipster dependencies BOM
Expand Down Expand Up @@ -428,7 +428,7 @@ dependencies {
implementation "com.ibm.icu:icu4j-charset:75.1"
implementation "com.github.seancfoley:ipaddress:5.5.0"
implementation "org.apache.maven:maven-model:3.9.8"
// NOTE: 3.0.2 is broken for splitting lecture PDFs
// NOTE: 3.0.2 is broken for splitting lecture specific PDFs
implementation "org.apache.pdfbox:pdfbox:3.0.1"
implementation "org.apache.commons:commons-csv:1.11.0"
implementation "org.commonmark:commonmark:0.22.0"
Expand Down Expand Up @@ -471,7 +471,7 @@ dependencies {
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"
testImplementation "io.github.classgraph:classgraph:4.8.174"
testImplementation "org.awaitility:awaitility:4.2.1"
testImplementation "org.awaitility:awaitility:4.2.2"
testImplementation "org.apache.maven.shared:maven-invoker:3.3.0"
testImplementation "org.gradle:gradle-tooling-api:8.9"
testImplementation "org.apache.maven.surefire:surefire-report-parser:3.3.1"
Expand Down
2 changes: 2 additions & 0 deletions docker/artemis/config/prod-singlenode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EUREKA_CLIENT_REGISTERWITHEUREKA=false
EUREKA_CLIENT_FETCHREGISTRY=false
1 change: 1 addition & 0 deletions docker/test-server-mysql-localci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- ${DOCKER_GROUP_ID:-0}
env_file:
- ${ARTEMIS_ENV_FILE:-./artemis/config/prod.env}
- ./artemis/config/prod-singlenode.env
volumes:
- ${ARTEMIS_VOLUME_MOUNT:-./.docker-data/artemis-data}:/opt/artemis/data
- ${ARTEMIS_LEGAL_MOUNT:-./.docker-data/artemis-legal}:/opt/artemis/legal
Expand Down
1 change: 1 addition & 0 deletions docker/test-server-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
restart: always
env_file:
- ${ARTEMIS_ENV_FILE:-./artemis/config/prod.env}
- ./artemis/config/prod-singlenode.env
volumes:
- ${ARTEMIS_VOLUME_MOUNT:-./.docker-data/artemis-data}:/opt/artemis/data
- ${ARTEMIS_LEGAL_MOUNT:-./.docker-data/artemis-legal}:/opt/artemis/legal
Expand Down
1 change: 1 addition & 0 deletions docker/test-server-postgresql-localci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- ${DOCKER_GROUP_ID:-0}
env_file:
- ${ARTEMIS_ENV_FILE:-./artemis/config/prod.env}
- ./artemis/config/prod-singlenode.env
volumes:
- ${ARTEMIS_VOLUME_MOUNT:-./.docker-data/artemis-data}:/opt/artemis/data
- ${ARTEMIS_LEGAL_MOUNT:-./.docker-data/artemis-legal}:/opt/artemis/legal
Expand Down
1 change: 1 addition & 0 deletions docker/test-server-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
restart: always
env_file:
- ${ARTEMIS_ENV_FILE:-./artemis/config/prod.env}
- ./artemis/config/prod-singlenode.env
volumes:
- ${ARTEMIS_VOLUME_MOUNT:-./.docker-data/artemis-data}:/opt/artemis/data
- ${ARTEMIS_LEGAL_MOUNT:-./.docker-data/artemis-legal}:/opt/artemis/legal
Expand Down
69 changes: 68 additions & 1 deletion docs/dev/guidelines/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ In order to load the relationships of an entity on demand, we then use one of 3
@EntityGraph(type = LOAD, attributePaths = { "exercises", "exercises.categories", "exercises.teamAssignmentConfig" })
Course findWithEagerExercisesById(long courseId);
2. **JOIN FETCH**: The ``JOIN FETCH`` keyword is used in a custom query to specify a graph of relationships to fetch. It should be used when a query is custom and has a custom ``@Query`` annotation. Example:
2. **JOIN FETCH**: The ``JOIN FETCH`` keyword is used in a custom query to specify a graph of relationships to fetch. It should be used when a query is custom and has a custom ``@Query`` annotation. You can see the example below. Also, explicitly or implicitly limiting queries in Hibernate can lead to in-memory paging. For more details, see the 'In-memory paging' section.

.. code-block:: java
Expand Down Expand Up @@ -204,6 +204,73 @@ In order to load the relationships of an entity on demand, we then use one of 3
final Set<ProgrammingExerciseFetchOptions> fetchOptions = withGradingCriteria ? Set.of(GradingCriteria, AuxiliaryRepositories) : Set.of(AuxiliaryRepositories);
var programmingExercise = programmingExerciseRepository.findByIdWithDynamicFetchElseThrow(exerciseId, fetchOptions);
4. **In memory paging**: Since the flag ``hibernate.query.fail_on_pagination_over_collection_fetch: true`` is now active, it is crucial to carefully craft database queries that involve FETCH statements with collections and thoroughly test the changes. In-memory paging would cause performance decrements and is, therefore, disabled. Any use of it will lead to runtime errors.
Queries that may result in this error can return Page<> and contain JOIN FETCHES or involve internal limiting in Hibernate, such as findFirst, findLast, or findOne. One solution is to split the original query into multiple queries and a default method. The first query fetches only the IDs of entities whose full dependencies need to be fetched. The second query eagerly fetches all necessary dependencies, and the third query uses counting to build Pages, if they are utilized.
When possible, use the default Spring Data/JPA methods for second(fetching) and third(counting) queries.
An example implementation could look like this:

.. code-block:: java
// Repository interface
default Page<User> searchAllByLoginOrNameInCourseAndReturnPage(Pageable pageable, String loginOrName, long courseId) {
List<Long> userIds = findUserIdsByLoginOrNameInCourse(loginOrName, courseId, pageable).stream().map(DomainObject::getId).toList();;
if (userIds.isEmpty()) {
return new PageImpl<>(Collections.emptyList(), pageable, 0);
}
List<User> users = findUsersWithGroupsByIds(userIds);
long total = countUsersByLoginOrNameInCourse(loginOrName, courseId);
return new PageImpl<>(users, pageable, total);
}
@Query("""
SELECT DISTINCT user
FROM User user
JOIN user.groups userGroup
JOIN Course course ON course.id = :courseId
WHERE user.isDeleted = FALSE
AND (
user.login LIKE :#{#loginOrName}%
OR CONCAT(user.firstName, ' ', user.lastName) LIKE %:#{#loginOrName}%
)
AND (course.studentGroupName = userGroup
OR course.teachingAssistantGroupName = userGroup
OR course.editorGroupName = userGroup
OR course.instructorGroupName = userGroup
)
""")
List<User> findUsersByLoginOrNameInCourse(@Param("loginOrName") String loginOrName, @Param("courseId") long courseId, Pageable pageable);
@Query("""
SELECT DISTINCT user
FROM User user
LEFT JOIN FETCH user.groups userGroup
WHERE user.id IN :ids
""")
List<User> findUsersWithGroupsByIds(@Param("ids") List<Long> ids);
@Query("""
SELECT COUNT(DISTINCT user)
FROM User user
JOIN user.groups userGroup
JOIN Course course ON course.id = :courseId
WHERE user.isDeleted = FALSE
AND (
user.login LIKE :#{#loginOrName}%
OR CONCAT(user.firstName, ' ', user.lastName) LIKE %:#{#loginOrName}%
)
AND (
course.studentGroupName = userGroup
OR course.teachingAssistantGroupName = userGroup
OR course.editorGroupName = userGroup
OR course.instructorGroupName = userGroup
)
""")
long countUsersByLoginOrNameInCourse(@Param("loginOrName") String loginOrName, @Param("courseId") long courseId);
Best Practices
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jgit_version=6.10.0.202406032230-r
sshd_version=2.13.2
checkstyle_version=10.17.0
jplag_version=5.1.0
slf4j_version=2.0.13
slf4j_version=2.0.16
sentry_version=7.13.0
liquibase_version=4.29.1
docker_java_version=3.4.0
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ module.exports = {
coverageThreshold: {
global: {
// TODO: in the future, the following values should increase to at least 90%
statements: 87.06,
branches: 73.30,
functions: 81.28,
lines: 87.14,
statements: 87.22,
branches: 73.40,
functions: 81.54,
lines: 87.29,
},
},
coverageReporters: ['clover', 'json', 'lcov', 'text-summary'],
Expand Down
Loading

0 comments on commit 7de8ab5

Please sign in to comment.