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
AG - added column called username to leaderboard that maps user id to the correct username #37
Conversation
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 approve
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.
Merge 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.
LGTM
b3081cf
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.
LGTM
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.
LGTM
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.
lgtm
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 PR has many issues that need to be addressed before it is mergeable.
It does work... I tested it on QA. But it may very well undo several other changes, and therefore break things that were already fixed.
And it includes huge formatting changes that make it very difficult to review. Those would be considered quite a nuisance in a professional shop. Formatting updates are welcome, but should be isolated in their own separate PRs.
// var tableStyle = { | ||
// "background": "white" | ||
// }; |
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 are we commenting out these three lines?
This is undoing someone else's work. Please don't do that.
@@ -26,7 +26,7 @@ export default function OurTable({ columns, data, testid = "testid", ...rest }) | |||
}, useSortBy) | |||
|
|||
return ( | |||
<Table style={tableStyle} {...getTableProps()} striped bordered hover > | |||
<Table {...getTableProps()} striped bordered hover > |
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 are we undoing someone else's work here? Please don't!
// Thats why only need to compare the current totalWealth to the cowPrice, because this implies that | ||
// totalWealth - cowPrice aka current totalWealth will not be enough to buy a cow. | ||
if(!(userCommons.totalWealth < commons.cowPrice)) toast(`Cow bought!`); | ||
else toast(`You can't buy a cow because you don't have enough money`) | ||
toast(`Cow bought!`); |
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.
Again.. undoing other people's work is not acceptable.
I think you might need to merge in the latest changes from main.
|
||
@Column(name="user_id") | ||
private long userId; | ||
private String username; |
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 not how this should be done. Instead, you should look up the username from the user's table. This is storing redundant data, which violates the principles of good database design.
@AutoConfigureDataJpa | ||
public class CommonsControllerTests extends ControllerTestCase { | ||
|
||
@MockBean | ||
UserCommonsRepository userCommonsRepository; | ||
|
||
@MockBean | ||
UserRepository userRepository; | ||
|
||
@MockBean | ||
CommonsRepository commonsRepository; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@WithMockUser(roles = { "ADMIN" }) | ||
@Test | ||
public void createCommonsTest() throws Exception { | ||
LocalDateTime someTime = LocalDateTime.parse("2022-03-05T15:50:10"); | ||
LocalDateTime someOtherTime = LocalDateTime.parse("2022-04-20T15:50:10"); | ||
|
||
Commons commons = Commons.builder() | ||
.name("Jackson's Commons") | ||
.cowPrice(500.99) | ||
.milkPrice(8.99) | ||
.startingBalance(1020.10) | ||
.startingDate(someTime) | ||
.endingDate(someOtherTime) | ||
.degradationRate(50.0) | ||
.showLeaderboard(false) | ||
.build(); | ||
|
||
CreateCommonsParams parameters = CreateCommonsParams.builder() | ||
.name("Jackson's Commons") | ||
.cowPrice(500.99) | ||
.milkPrice(8.99) | ||
.startingBalance(1020.10) | ||
.startingDate(someTime) | ||
.endingDate(someOtherTime) | ||
.degradationRate(50.0) | ||
.showLeaderboard(false) | ||
.build(); | ||
|
||
String requestBody = objectMapper.writeValueAsString(parameters); | ||
String expectedResponse = objectMapper.writeValueAsString(commons); | ||
|
||
when(commonsRepository.save(commons)) | ||
.thenReturn(commons); | ||
|
||
MvcResult response = mockMvc | ||
.perform(post("/api/commons/new").with(csrf()) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.characterEncoding("utf-8") | ||
.content(requestBody)) | ||
.andExpect(status().isOk()) | ||
.andReturn(); | ||
|
||
verify(commonsRepository, times(1)).save(commons); | ||
|
||
String actualResponse = response.getResponse().getContentAsString(); | ||
assertEquals(expectedResponse, actualResponse); | ||
} | ||
@MockBean | ||
UserCommonsRepository userCommonsRepository; | ||
|
||
@MockBean |
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 this is only whitespace/formatting changes, PLEASE DON'T DO THIS.
It makes your PR super hard to code review, because we have to look at every blessed line to make sure you didn't delete or add something.
Fixing formatting should be done in a separate PR that ONLY focuses on fixing formatting.
@@ -44,40 +44,42 @@ | |||
@AutoConfigureDataJpa |
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 this is only whitespace/formatting changes, PLEASE DON'T DO THIS.
It makes your PR super hard to code review, because we have to look at every blessed line to make sure you didn't delete or add something.
Fixing formatting should be done in a separate PR that ONLY focuses on fixing formatting.
issues get fixed in #65 |
Overview
Changes
Backend
Frontend