Skip to content

Commit

Permalink
Merge branch 'develop' into feature/removable/link-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
pellumbbaboci authored Oct 15, 2023
2 parents c0c3c47 + 60927d0 commit 3c79ab9
Show file tree
Hide file tree
Showing 173 changed files with 3,688 additions and 1,467 deletions.
108 changes: 80 additions & 28 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,78 @@
const esModules = ['lodash-es', 'franc-min', 'trigram-utils', 'n-gram', 'collapse-white-space', '@angular/animations', '@angular/common', '@ls1intum/apollon',
'@angular/compiler', '@angular/core', '@angular/forms', '@angular/localize', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router',
'@ngx-translate/core', '@ngx-translate/http-loader', '@fortawesome/angular-fontawesome', '@angular/cdk', '@angular/material', '@angular/cdk', 'dayjs/esm',
'rxjs/operators', '@ng-bootstrap/ng-bootstrap', 'ngx-webstorage', '@ctrl/ngx-emoji-mart', 'ngx-device-detector', '@swimlane/ngx-charts',
'@angular/service-worker', '@danielmoncada/angular-datetime-picker', '@flaviosantoro92/ngx-datatable', 'd3-color', 'd3-interpolate', 'd3-transition', 'd3-brush',
'd3-drag', 'd3-selection', 'd3-scale', 'd3-array', 'd3-format', 'd3-shape', 'd3-path', 'd3-ease', 'd3-time', 'd3-hierarchy', 'ngx-infinite-scroll', 'internmap',
'@swimlane/ngx-graph'].join('|');
const esModules = [
'lodash-es',
'franc-min',
'trigram-utils',
'n-gram',
'collapse-white-space',
'@angular/animations',
'@angular/common',
'@ls1intum/apollon',
'@angular/compiler',
'@angular/core',
'@angular/forms',
'@angular/localize',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@ngx-translate/core',
'@ngx-translate/http-loader',
'@fortawesome/angular-fontawesome',
'@angular/cdk',
'@angular/material',
'@angular/cdk',
'dayjs/esm',
'rxjs/operators',
'@ng-bootstrap/ng-bootstrap',
'ngx-webstorage',
'@ctrl/ngx-emoji-mart',
'ngx-device-detector',
'@swimlane/ngx-charts',
'@angular/service-worker',
'@danielmoncada/angular-datetime-picker',
'@flaviosantoro92/ngx-datatable',
'd3-color',
'd3-interpolate',
'd3-transition',
'd3-brush',
'd3-drag',
'd3-selection',
'd3-scale',
'd3-array',
'd3-format',
'd3-shape',
'd3-path',
'd3-ease',
'd3-time',
'd3-hierarchy',
'ngx-infinite-scroll',
'internmap',
'@swimlane/ngx-graph',
].join('|');

const {
compilerOptions: { baseUrl = './' },
} = require('./tsconfig.json');

module.exports = {
globalSetup: 'jest-preset-angular/global-setup',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.html$',
isolatedModules: true,
diagnostics: {
ignoreCodes: [151001],
},
},
},
testEnvironmentOptions: {
url: 'https://artemis.fake/test'
url: 'https://artemis.fake/test',
},
roots: ['<rootDir>', `<rootDir>/${baseUrl}`],
modulePaths: [`<rootDir>/${baseUrl}`],
setupFiles: ['jest-date-mock'],
cacheDirectory: '<rootDir>/build/jest-cache',
coverageDirectory: '<rootDir>/build/test-results/',
reporters: ['default', ['jest-junit', { outputDirectory: '<rootDir>/build/test-results/', outputName: 'TESTS-results-jest.xml' }]],
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: '<rootDir>/build/test-results/',
outputName: 'TESTS-results-jest.xml',
},
],
],
collectCoverageFrom: ['src/main/webapp/**/*.{js,jsx,ts,tsx}', '!src/main/webapp/**/*.module.{js,jsx,ts,tsx}'],
coveragePathIgnorePatterns: [
'/node_modules/',
Expand All @@ -53,24 +95,34 @@ module.exports = {
'src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts',
'src/main/webapp/app/exam/manage/exam-management.route.ts',
'src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts',
'src/main/webapp/app/core/config/prod.config.ts'
'src/main/webapp/app/core/config/prod.config.ts',
],
coverageThreshold: {
global: {
// TODO: in the future, the following values should increase to at least 90%
statements: 85.6,
branches: 72.8,
functions: 79.4,
lines: 85.8,
statements: 85.9,
branches: 73.2,
functions: 79.7,
lines: 86.1,
},
},
coverageReporters: ["clover", "json", "lcov", "text-summary"],
coverageReporters: ['clover', 'json', 'lcov', 'text-summary'],
setupFilesAfterEnv: ['<rootDir>/src/test/javascript/spec/jest-test-setup.ts', 'jest-extended/all'],
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'],
resolver: '<rootDir>/jest.resolver.js',
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': 'jest-preset-angular',
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.html$',
isolatedModules: true,
diagnostics: {
ignoreCodes: [151001],
},
},
],
},
modulePathIgnorePatterns: [],
testTimeout: 3000,
Expand All @@ -84,7 +136,7 @@ module.exports = {
'<rootDir>/src/test/javascript/spec/util/**/*.spec.ts',
'<rootDir>/src/test/javascript/spec/interceptor/**/*.spec.ts',
'<rootDir>/src/test/javascript/spec/config/**/*.spec.ts',
'<rootDir>/src/test/javascript/spec/core/**/*.spec.ts'
'<rootDir>/src/test/javascript/spec/core/**/*.spec.ts',
],
moduleNameMapper: {
'^app/(.*)': '<rootDir>/src/main/webapp/app/$1',
Expand All @@ -94,6 +146,6 @@ module.exports = {
'@env': '<rootDir>/src/main/webapp/environments/environment',
'@src/(.*)': '<rootDir>/src/src/$1',
'@state/(.*)': '<rootDir>/src/app/state/$1',
"^lodash-es$": "lodash"
'^lodash-es$': 'lodash',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public class IrisSubSettings extends DomainObject {
@Column(name = "preferredModel")
private String preferredModel;

@Nullable
@Column(name = "rateLimit")
private Integer rateLimit;

@Nullable
@Column(name = "rateLimitTimeframeHours")
private Integer rateLimitTimeframeHours;

public boolean isEnabled() {
return enabled;
}
Expand All @@ -57,4 +65,22 @@ public String getPreferredModel() {
public void setPreferredModel(@Nullable String preferredModel) {
this.preferredModel = preferredModel;
}

@Nullable
public Integer getRateLimit() {
return rateLimit;
}

public void setRateLimit(@Nullable Integer rateLimit) {
this.rateLimit = rateLimit;
}

@Nullable
public Integer getRateLimitTimeframeHours() {
return rateLimitTimeframeHours;
}

public void setRateLimitTimeframeHours(@Nullable Integer rateLimitTimeframeHours) {
this.rateLimitTimeframeHours = rateLimitTimeframeHours;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
public interface ParticipationRepository extends JpaRepository<Participation, Long> {

@Query("""
SELECT DISTINCT p FROM Participation p
LEFT JOIN FETCH p.results
LEFT JOIN FETCH p.submissions s
LEFT JOIN FETCH s.results
SELECT DISTINCT p
FROM Participation p
LEFT JOIN FETCH p.results
LEFT JOIN FETCH p.submissions s
LEFT JOIN FETCH s.results
WHERE p.id = :#{#participationId}
""")
Optional<Participation> findByIdWithResultsAndSubmissionsResults(@Param("participationId") Long participationId);

@Query("""
SELECT p FROM Participation p
LEFT JOIN FETCH p.submissions s
LEFT JOIN FETCH s.results r
SELECT p
FROM Participation p
LEFT JOIN FETCH p.submissions s
LEFT JOIN FETCH s.results r
WHERE p.id = :participationId
AND (s.id = (SELECT max(s2.id) FROM p.submissions s2) OR s.id = NULL)
""")
Expand All @@ -49,9 +51,10 @@ default Participation findByIdWithLatestSubmissionElseThrow(Long participationId
}

@Query("""
SELECT p FROM Participation p
LEFT JOIN FETCH p.submissions s
WHERE p.id = :#{#participationId}
SELECT p
FROM Participation p
LEFT JOIN FETCH p.submissions s
WHERE p.id = :participationId
AND (s.type <> 'ILLEGAL' OR s.type IS NULL)
""")
Optional<Participation> findWithEagerLegalSubmissionsById(@Param("participationId") Long participationId);
Expand All @@ -61,6 +64,19 @@ default Participation findByIdWithLegalSubmissionsElseThrow(long participationId
return findWithEagerLegalSubmissionsById(participationId).orElseThrow(() -> new EntityNotFoundException("Participation", participationId));
}

@Query("""
SELECT p
FROM Participation p
LEFT JOIN FETCH p.submissions s
WHERE p.id = :participationId
""")
Optional<Participation> findWithEagerSubmissionsById(@Param("participationId") Long participationId);

@NotNull
default Participation findByIdWithSubmissionsElseThrow(long participationId) {
return findWithEagerSubmissionsById(participationId).orElseThrow(() -> new EntityNotFoundException("Participation", participationId));
}

@NotNull
default Participation findByIdElseThrow(long participationId) {
return findById(participationId).orElseThrow(() -> new EntityNotFoundException("Participation", participationId));
Expand All @@ -69,15 +85,15 @@ default Participation findByIdElseThrow(long participationId) {
@Query("""
SELECT max(p.individualDueDate)
FROM Participation p
WHERE p.exercise.id = :#{#exerciseId}
WHERE p.exercise.id = :exerciseId
AND p.individualDueDate IS NOT null
""")
Optional<ZonedDateTime> findLatestIndividualDueDate(@Param("exerciseId") Long exerciseId);

@Query("""
SELECT min(p.individualDueDate)
FROM Participation p
WHERE p.exercise.id = :#{#exerciseId}
WHERE p.exercise.id = :exerciseId
AND p.individualDueDate IS NOT null
""")
Optional<ZonedDateTime> findEarliestIndividualDueDate(@Param("exerciseId") Long exerciseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ default Page<UserDTO> searchAllUsersByLoginOrNameInGroupAndConvertToDTO(Pageable
*/
@EntityGraph(type = LOAD, attributePaths = { "groups", "authorities" })
@Query("""
SELECT user
SELECT DISTINCT user
FROM User user
WHERE user.isDeleted = false AND user.login IN :#{#logins}
""")
List<User> findAllByLogins(@Param("logins") Set<String> logins);
Set<User> findAllByLogins(@Param("logins") Set<String> logins);

/**
* Searches for users by their login or full name.
Expand Down
Loading

0 comments on commit 3c79ab9

Please sign in to comment.