Created
March 29, 2011 17:05
-
-
Save coderberry/892766 to your computer and use it in GitHub Desktop.
Blog Post 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Count duplicate submissions within 45 days | |
| * SELECT count(l.id) | |
| * FROM lead AS l, submission AS s, buyerLog as bl | |
| * WHERE l.id = s.leadId | |
| * AND s.id = bl.submissionId | |
| * AND bl.leadBuyer = $buyerName | |
| * AND l.id != $lead.id | |
| * AND l.dateCreated::date > $daysAgo | |
| */ | |
| protected def Boolean isDuplicateSubmission(Lead lead, ArrayList<String> buyerNames) { | |
| def isDuplicate = false | |
| def daysAgo = new Date() - 45 | |
| def cnt = Lead.withCriteria { | |
| not { | |
| idEq(lead.id) | |
| } | |
| and { | |
| le('dateCreated', daysAgo) | |
| submissions { | |
| buyerLogs { | |
| inList('leadBuyer', buyerNames) | |
| } | |
| } | |
| } | |
| projections { | |
| rowCount() | |
| } | |
| } | |
| return (cnt > 0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment