-
Notifications
You must be signed in to change notification settings - Fork 25
I79 clarification announcement fixes #1038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
I79 clarification announcement fixes #1038
Conversation
There are a lot of garbage console.log() that I used for debugging, I will delete them. The functionality works though. |
removed. |
Programs.lnk
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file submitted as part of the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dummy reply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file submitted as part of the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
//This method is used by two (or more?) methods. | ||
//Whenever an announcement that this user should receive is made this method is called | ||
//Also whenever the team sends a clarification to be answered by the judges. | ||
if ( !arg0.isAnswered()) { //case when the team sends a clarification to be answered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the default template parameter name ("arg0") was changed to something more meaningful, like "clar" or "clarification".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am here just following the general structure of the file. If that is the case, every method needs to change as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my answer is satisfactory, I will close this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind this was originally written by students and didn't go through the vigorous review process we do for PC2. I don't thing we have to change all the existing code, but there is no sense in propagating bad practices by putting good code after bad. I think we should change NEW code to be as readable as possible. That is, I would change arg0
to something meaningful, eg. clar
or newClar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright.
@@ -0,0 +1,9 @@ | |||
<h1 mat-dialog-title>Clarification Announcement Received</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest the title here be just "Announcement Received", in order to avoid confusion between what's a "clarification" vs. what's an "announcement". (PC2 is, currently, treating "announcements" as "clarifications", but it seems to make more sense from the user's perspective to keep the two notions separate.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For similar reasons I think it would make sense to rename all of the components which are named like new-announcement-clarification-alert
to be just new-announcement-alert
. It would simplify the naming and at the same time help maintain the distinction between "announcements" and "clarifications".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I say clarification announcement is to emphasize the fact that announcements are essentially a special form of clarification. The term "announcement clarification" was decided when I was building this feature in pc2. Of course that can be discussed and changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's no CSS associated with this new component, what is the browser going to use for rendering it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this gets used?
templateUrl: './new-announcement-alert.component.html', | ||
styleUrls: ['./new-announcement-alert.component.scss'] | ||
}) | ||
export class NewClarificationAnnoucementAlertComponent implements OnInit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name of class is misspelled (Annoucement -> Announcement). This should be fixed, and the change propogated throughout the code.
projects/WTI-UI/src/app/modules/core/abstract-services/i-websocket.service.ts
Outdated
Show resolved
Hide resolved
@@ -13,12 +14,22 @@ export class UiHelperService { | |||
private _matSnackBar: MatSnackBar) { } | |||
|
|||
incomingClarification(id: string): void { | |||
console.log('clarification incoming : Alert will be initiated if alert is enabled.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you were going to remove console logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as above.
if (this.enableClarificationNotifications) { | ||
this._dialogService.open(NewClarificationAlertComponent, { | ||
data: { id } | ||
}); | ||
} | ||
} | ||
|
||
incomingClarificationAnnouncement(id: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest renaming this to incomingAnnouncement
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to decide if we are going to use the term clarification announcement or announcement.
if (this.enableClarificationNotifications) { | ||
this._dialogService.open(NewClarificationAlertComponent, { | ||
data: { id } | ||
}); | ||
} | ||
} | ||
|
||
incomingClarificationAnnouncement(id: string): void { | ||
console.log('Announcement incoming : Alert will be initiated if alert is enabled.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove logging?
@@ -36,7 +36,9 @@ export class RunsPageComponent implements OnInit, OnDestroy { | |||
|
|||
// when runs are updated, trigger a reload | |||
this._teamService.runsUpdated | |||
.pipe(takeUntil(this._unsubscribe)) | |||
.pipe( | |||
delay(300), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you at least document/explain in comments why the delay(300)
is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because without delay the refresh happens too quickly and, it misses the new pending clarifications.
@@ -34,7 +34,9 @@ export class ClarificationsPageComponent implements OnInit, OnDestroy { | |||
this.loadClars(); | |||
|
|||
this._contestService.clarificationsUpdated | |||
.pipe(takeUntil(this._unsubscribe)) | |||
.pipe( | |||
delay(300), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you at least document/explain in comments why the delay(300)
is now needed?
|
||
if (fitlerParams.receipient === 'all') { filtered = filtered.filter(x => x.recipient === 'All'); console.log('receipient is ALl');} | ||
if (fitlerParams.receipient === 'team') { filtered = filtered.filter(x => x.recipient !== 'All'); console.log('receipient is a team')} | ||
if (fitlerParams.problem) { filtered = filtered.filter(x => x.problem === fitlerParams.problem); console.log('receipient is a problem')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments about the changes in the above three lines:
- I don't think the console logging is necessary any longer; if you agree then I suggest removing it.
- These changes conflict with related changes proposed in PR I1030 WTI clar announcement filtering #1041. That's fine; collisions are to be expected when multiple people are working in similar areas of the code. I just note it here so we'll remember that the conflicts will need to be resolved in whichever PR is merged later.
- (If you do remove the console logging, then I think these lines will no longer conflict?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the console logging should be removed.
@@ -5,12 +5,14 @@ import { SharedModule } from '../shared/shared.module'; | |||
import { ReactiveFormsModule } from '@angular/forms'; | |||
import { NewClarificationComponent } from './components/new-clarification/new-clarification.component'; | |||
import { NewClarificationAlertComponent } from './components/new-clarification-alert/new-clarification-alert.component'; | |||
import { NewClarificationAnnoucementAlertComponent } from './components/new-announcement-clarification-alert/new-announcement-alert.component'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component name is misspelled (Annoucement
should be Announcement
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
|
||
@NgModule({ | ||
declarations: [ | ||
ClarificationsPageComponent, | ||
NewClarificationComponent, | ||
NewClarificationAlertComponent | ||
NewClarificationAlertComponent, | ||
NewClarificationAnnoucementAlertComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component name is misspelled. Also, see comments on subsequent files; I think this component should be named simply NewAnnouncementAlertComponent
in order to distinguish "Clarifications" from "Announcements". Again, see subsequent comments for further details.
@@ -1,5 +1,5 @@ | |||
package WebsocketEnums; | |||
|
|||
public enum WebsocketMsgType { | |||
UNDEFINED, JUDGED, CONTEST_CLOCK, TEST, CLARIFICATION, STANDINGS, CONNECTION_DROPPED | |||
UNDEFINED, JUDGED, CONTEST_CLOCK, TEST, CLARIFICATION, CLARIFICATION_ANNOUNCEMENT, STANDINGS, CONNECTION_DROPPED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest CLARIFICATION_ANNOUNCEMENT
be renamed to just ANNOUNCEMENT
. See additional comments in following files for some explanation of why I think that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed all the changed files and left comments. I would like to see some of the things I mentioned fixed, but they don't amount to "errors" in the code.
However, when I try to build and run the PR code, I get errors (specifically, building the WTI-UI project for inclusion into the WTI distribution produces main.js
and polyfills.js
files which are marked as having large numbers of errors). Does package.xml
in the PC2 Project produce a build, with no errors in WTI WebContent, for you? (If so, then there is something different about our configurations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed file Programs.lnk
....
Programs.lnk
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dummy reply.
Think I made it work without delays, will need to test more and resolve the comments above but I'm sleepy so later. |
console.error('error submitting new clarification'); | ||
console.error(error); | ||
}, | ||
complete: () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this empty routine necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this helps people looking at the code know that there is another callback option called complete.
let fixture: ComponentFixture<NewAnnouncementAlertComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is TestBed
and why do we need it? I know little about the typescript environment, so I have no idea why this is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It provides a simulated Angular module environment for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add it just for local testing or is it something required for production?
}, | ||
error: (error: any) => { | ||
this._uiHelper.alertError('Error submitting clarification!'); | ||
console.error('error submitting new clarification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we leaving the console.error? I thought we were removing them, especially since you have an alertError there...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a particular reason if this message is triggered, add why the error came in the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright.
if (clars && clars.length > 0) { | ||
const clar = clars.find(x => x.id === clarId); | ||
if (!clar) { | ||
console.error('Announcement clarification not found! invalid ID passed via websocket'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we leaving these console.error messages? Maybe control them by a flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is supposed to be seen by an user, maybe make the message less technical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag src/constants.ts does not exist in this branch so for now i cannot use the flag. I think this is an important console.log so i'm hessitant on removing it completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without knowing too much about TS and the interaction between these angular modules, it seems like it's OK to me (other than the couple of minorconsole.error
calls that I mentioned).
I did test it, and it does work for clars and runs as one would expect it to.
|
||
this.client.sendMessage(builder.toString()); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a tab space for each line of code after this line, in this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what I need to do here. The tabbing seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, the function body should have a tab indentation after the definition line. So, lines 23-26 should have a tab space. Similarly, lines 37-45. The current way does not make it wrong but makes the code more readable.
.add("teamId", this.teamId) | ||
.build(); | ||
|
||
this.client.sendMessage(builder.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a tab space for this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 66
@@ -499,6 +499,7 @@ public Response submitClarification( | |||
.entity(new ServerErrorResponseModel(Response.Status.UNAUTHORIZED, "Unauthorized user request")) | |||
.type(MediaType.APPLICATION_JSON).build(); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason you added a blank single line in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is an empty file added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think changes to the binaries after compilation should be pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
let fixture: ComponentFixture<NewAnnouncementAlertComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add it just for local testing or is it something required for production?
if (clars && clars.length > 0) { | ||
const clar = clars.find(x => x.id === clarId); | ||
if (!clar) { | ||
console.error('Announcement clarification not found! invalid ID passed via websocket'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is supposed to be seen by an user, maybe make the message less technical.
}, | ||
error: (error: any) => { | ||
this._uiHelper.alertError('Error submitting clarification!'); | ||
console.error('error submitting new clarification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a particular reason if this message is triggered, add why the error came in the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the filter
and simply changed the line for the method arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I see your concern for dev and production env however I dont think it is a big deal to have some tests on production since it is not a big project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its clearly not being used. I don't see the point of importing functions/methods that are not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn't have a copyright comment in the beginning. If it makes sense, add it. Similarly, do it for the other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well WTI was made by some student group so pc2 copyright wouldnt apply.
I'm working on reviewing this PR. The first thing I did is clone your pc2v9 repo fork. Then I looked for a branch named to correspond with Issue #79 -- but didn't find one. Finally I found |
When I created the PR I couldnt manage to find the issue so I left to number part blank. Somewhat scared of renaming it. Will github continue to track it? |
I just cloned a new copy of the @kkarakas github fork, switched to the
Is anyone else able to build the project on this branch? |
I did get that issue, and I simply put a the copy of pc2.jar from the "pc2v9/dist" folder in there to try to get it to build. After that, I did that I get ANOTHER different error, and I'm not sure why this is:
BTW, I am building using " |
Description of what the PR does
When there is an announcement WTI does not immediately warn the client.
When WTI asks a clarification, there should be pending status clarification.
Ditto for submitting a problem.
Issue which the PR addresses
Fixes #79
Environment in which the PR was developed (OS,IDE, Java version, etc.)
Windows 11
Precise steps for testing the PR (i.e., how to demonstrate that it works correctly)