Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

archit-gpt
Copy link
Contributor

Overview

  1. when a user joins a commons, the UserCommon's repository now saves a username parameter that is the current user's google full name (this can be easily changed to email, firstname, or last name).
  2. a username column was added to the leaderboard page that displays all users in common with their username from (1).

Changes

Backend

  • UserCommons.java: added username to UserCommons
  • CommonsController.java: username gets initialized as current user's name, UserCommons gets built when a player joins
  • UserCommonsControllerTests.java: updated all tests
  • CommonsControllerTests.java: updated all tests

Frontend

  • LeaderboardTable.js : added the username column to the table
  • LeaderboardTable.test.js: updated all tests
  • leaderboardFixtures.js: updated fixtures

@archit-gpt archit-gpt self-assigned this Nov 28, 2022
@archit-gpt archit-gpt changed the title added column called username to leaderboard that maps user id to the correct username AG - added column called username to leaderboard that maps user id to the correct username Nov 28, 2022
@pconrad pconrad added FIXME: Peer CR Please get a peer code review FIXME: Add Team Label Please add the label for your team, e.g. f22-4pm-3 labels Nov 28, 2022
@archit-gpt archit-gpt added f22-7pm-4 f22-7pm-4 and removed FIXME: Add Team Label Please add the label for your team, e.g. f22-4pm-3 labels Nov 28, 2022
RAILGUN1124
RAILGUN1124 previously approved these changes Nov 28, 2022
Copy link
Contributor

@RAILGUN1124 RAILGUN1124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i approve

@pconrad pconrad added STAFF: ready for review green on CI, has peer CR, no other obvious issues and removed FIXME: Peer CR Please get a peer code review labels Nov 28, 2022
Copy link

@nathanmathew02 nathanmathew02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge Conflict

tkumar07
tkumar07 previously approved these changes Nov 28, 2022
Copy link

@tkumar07 tkumar07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@archit-gpt archit-gpt dismissed stale reviews from tkumar07 and RAILGUN1124 via b3081cf November 28, 2022 22:23
Copy link

@nathanmathew02 nathanmathew02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ruiqiRichard ruiqiRichard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RAILGUN1124 RAILGUN1124 self-requested a review November 28, 2022 23:40
Copy link
Contributor

@RAILGUN1124 RAILGUN1124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pconrad pconrad temporarily deployed to f22-7pm-4-happycows November 28, 2022 23:55 Inactive
Copy link
Contributor

@pconrad pconrad left a 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.

Comment on lines +7 to +9
// var tableStyle = {
// "background": "white"
// };
Copy link
Contributor

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 >
Copy link
Contributor

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!

Comment on lines -66 to +65
// 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!`);
Copy link
Contributor

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;
Copy link
Contributor

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.

Comment on lines 48 to +54
@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
Copy link
Contributor

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
Copy link
Contributor

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.

@pconrad pconrad added FIXME: Changes Requested Please address the changes specified in the code review and removed STAFF: ready for review green on CI, has peer CR, no other obvious issues labels Nov 29, 2022
@ruiqiRichard
Copy link
Contributor

issues get fixed in #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f22-7pm-4 f22-7pm-4 FIXME: Changes Requested Please address the changes specified in the code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants