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

Feedback #1

Open
wants to merge 4 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 4 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Dec 7, 2024

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to the default branch since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to the default branch since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to the default branch. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @salesforcejene

opp.stageName = 'Qualification'; // Set the Opportunity's Stage to Qualification
opp.closeDate = Date.today().addMonths(3); // Set the Opportunity's Close Date to 3 months from today
opp.amount = 50000; // Set the Opportunity's Amount to 50000
System.debug(LoggingLevel.FINEST, 'Opportunity Name' + opp.Name);

Check warning

Code scanning / PMD

Debug statements contribute to longer transactions and consume Apex CPU time even when debug logs are not being captured. When possible make use of other debugging techniques such as the Apex Replay Debugger and Checkpoints that could cover *most* use cases. For other valid use cases that the statement is in fact valid make use of the `@SuppressWarnings` annotation or the `//NOPMD` comment. Warning

Avoid debug statements since they impact on performance

Choose a reason for hiding this comment

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

Try to take debugs out of the final submission if they are not needed anymore.

Copy link

@fritzb100 fritzb100 left a comment

Choose a reason for hiding this comment

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

Hi Jené,
I see that you put a lot of hard work on this and it shows. Great Job!!
I just added a few things to try when you get a chance.

// Set the AccountId field to the given accountId

// Insert the Contact into the database

insert contact;

Choose a reason for hiding this comment

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

// Upsert the opportunities List so that records are either updated or created
upsert opportunities;

Choose a reason for hiding this comment

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

For the future, if you ever run into an error because you're updating the same list that you are iterating over, you'll need to create a new list and add to that list.

Comment on lines +177 to +181
insert matchedAccount;
} else {
matchedAccount = accountToInsert[0]; //Use the first record
}

Choose a reason for hiding this comment

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

Try to move the insert matchedAccount to line 181 and change it to an upsert

Comment on lines +198 to +210
for (String opp : oppNames) {
//add to listToBeUpserted only if opp name is not already in the existingOppsList
if(!existingOppsNames.contains(opp)) {
Opportunity oppsToAdd = new Opportunity(
Name = opp,
StageName = 'Prospecting',
Amount = 70000,
CloseDate = date.today().addMonths(2),
AccountId = matchedAccount.Id
);
// Add the Opportunity to the list
listOfOppsToBeUpserted.add(oppsToAdd);
}

Choose a reason for hiding this comment

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

Awesome! glad you were able to get through this one.

}
accounts.add(newAcc);
// Upsert the Account
upsert newAcc;

Choose a reason for hiding this comment

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

Try using a try and catch block to catch errors and handle them

List<Lead> listOfLeads = new List<Lead>();

// Loop through each Lead name
for (String l : leadNames){

Choose a reason for hiding this comment

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

Try to avoid using single letters as variables, make them a little descriptive if you can

Comment on lines +313 to +314
storeCase.add(caseToAdd);
caseToAdd.AccountId = accountId;

Choose a reason for hiding this comment

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

Try to reverse these two lines. Assign the AccountId before you add it to the list. Your way probably works too, just not accustomed to seeing it reversed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants