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 10 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 10 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Sep 13, 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: @snomis79

// The body of the method
//}
public static List<Lead> getAllLeads () {
List<Lead> allLeads = [SELECT Id, LastName, Company, Phone, Email FROM Lead];

Check warning

Code scanning / PMD

When working with very large amounts of data, unfiltered SOQL or SOSL queries can quickly cause [governor limit](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm) exceptions. Warning

Avoid SOQL queries without a where or limit statement
// The body of the method
//}
public static Integer getAccountCount () {
Integer count = [SELECT COUNT() FROM Account];

Check warning

Code scanning / PMD

When working with very large amounts of data, unfiltered SOQL or SOSL queries can quickly cause [governor limit](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm) exceptions. Warning

Avoid SOQL queries without a where or limit statement
@@ -225,7 +225,7 @@

// Assert that the number of cases returned is correct
System.assertEquals(1, cases.size(), 'Number of cases returned is incorrect.');

System.debug(cases);

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
@@ -225,7 +225,7 @@

// Assert that the number of cases returned is correct
System.assertEquals(1, cases.size(), 'Number of cases returned is incorrect.');

System.debug(cases);

Check warning

Code scanning / PMD

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. Warning

Calls to System.debug should specify a logging level.
@@ -142,16 +198,17 @@
* @return A list of Contact LastName.
*/
public static List<String> getContactNamesByAccount(Id accountId) {
// Create a list to hold the Contact LastNames
List<String>ContactsLastNames = new List<String>();

Check failure

Code scanning / PMD

Configurable naming conventions for local variable declarations. This rule reports variable declarations which do not match the regex that applies to their specific kind (e.g. local variable, or final local variable). Each regex can be configured through properties. By default this rule uses the standard Apex naming convention (Camel case). Error

The local variable name 'ContactsLastNames' doesn't match '[a-z][a-zA-Z0-9]*'
Copy link

@cyberjus cyberjus left a comment

Choose a reason for hiding this comment

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

This all looks really good, I have very little comments to make that would improve it. Beautifully formatted which makes it very easy to read. Good job.

Comment on lines +112 to +119
Date today = Date.today();
Date nextWeek = today.addDays(7);
List <Task> tasksDue = [
SELECT Id, Subject, ActivityDate
FROM Task
WHERE ActivityDate >= :today
AND ActivityDate <= :nextWeek
];
Copy link

Choose a reason for hiding this comment

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

You can use Date variables and binds for this. There are also relative date formula you can use in queries. Similar to the ones you can use in reports.

Comment on lines +168 to +169
WHERE Origin NOT IN ('Web', 'Email', '')
AND Origin != null
Copy link

Choose a reason for hiding this comment

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

In SOQL null and empty string evaluate to the same, so you shouldnt need the extra != NULL, but it is not hurting anything.

@@ -142,16 +198,17 @@ public with sharing class SOQL {
* @return A list of Contact LastName.
*/
public static List<String> getContactNamesByAccount(Id accountId) {
// Create a list to hold the Contact LastNames
List<String>ContactsLastNames = new List<String>();
Copy link

Choose a reason for hiding this comment

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

Suggested change
List<String>ContactsLastNames = new List<String>();
List<String> contactsLastNames = new List<String>();

// Return the total revenue
return null; // Replace null with the variable you used to store the result
AggregateResult[] results = [SELECT SUM(Amount) totalAmount FROM Opportunity WHERE StageName = :stage OR Amount > 10000];
Decimal totalRevenue = (Decimal)results[0].get('totalAmount');
Copy link

Choose a reason for hiding this comment

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

👍

Comment on lines +372 to +384
List<Account> accounts = [
SELECT Id, BillingState
FROM Account
WHERE Id = :accountId
];

String accountBillingState = accounts[0].BillingState;

// Store the Account's BillingState
List<Contact> contacts = [
SELECT Id, MailingState
FROM Contact
WHERE MailingState = :accountBillingState
];
Copy link

Choose a reason for hiding this comment

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

You can also do this as one query, see if you can figure out that syntax. HINT: you can use a query in the criteria


List<OpportunityLineItem> newLineItems = new List<OpportunityLineItem>();

Integer genNum = Integer.valueOf(Math.random() * 3 + 1);
Copy link

Choose a reason for hiding this comment

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

This probably should be within in the for loop so it is a random quantity every time. The instructions are a little unclear here and ultimately doesnt really matter.

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