Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/general/add-sidebar-card-medium-ho…
Browse files Browse the repository at this point in the history
…ver-effect
  • Loading branch information
laxerhd authored Nov 5, 2024
2 parents fd92a89 + fdc2501 commit a501e8b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,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.6.5.war
./artemis-server-cli deploy [email protected] -w build/libs/Artemis-7.7.0.war
```

## Architecture
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
}

group = "de.tum.cit.aet.artemis"
version = "7.6.5"
version = "7.7.0"
description = "Interactive Learning with Individual Feedback"

java {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "artemis",
"version": "7.6.5",
"version": "7.7.0",
"description": "Interactive Learning with Individual Feedback",
"private": true,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class RatingComponent implements OnInit, OnChanges {
public rating: number;
public disableRating = false;
@Input() result?: Result;
private previousResultId?: number;

constructor(
private ratingService: RatingService,
Expand All @@ -26,7 +27,8 @@ export class RatingComponent implements OnInit, OnChanges {
}

ngOnChanges(changes: SimpleChanges): void {
if (changes['result'] && !changes['result'].isFirstChange()) {
if (changes['result'] && changes['result'].currentValue?.id !== this.previousResultId) {
this.previousResultId = changes['result'].currentValue?.id;
this.loadRating();
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/javascript/spec/component/rating/rating.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ describe('RatingComponent', () => {
expect(ratingComponent.rating).toBe(2);
});

it('should not call loadRating if result ID remains the same', () => {
// without this condition the loadRating might be spammed making unnecessary api calls
const loadRatingSpy = jest.spyOn(ratingComponent, 'loadRating');
ratingComponent.result = { id: 90 } as Result;
ratingComponent.result.submission = { id: 1 } as Submission;
ratingComponent.result.participation = { id: 1 } as Participation;
jest.spyOn(ratingService, 'getRating').mockReturnValue(of(2));
ratingComponentFixture.detectChanges();
ratingComponent.result = { id: 90 } as Result;
ratingComponentFixture.detectChanges();
expect(loadRatingSpy).toHaveBeenCalledOnce();
expect(ratingComponent.rating).toBe(2);
});

describe('OnRate', () => {
beforeEach(() => {
ratingComponent.rating = 0;
Expand Down

0 comments on commit a501e8b

Please sign in to comment.