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

Handle salesforce objects with camelcase names correctly #238

Merged
merged 4 commits into from Dec 28, 2018

Conversation

pvighi
Copy link
Contributor

@pvighi pvighi commented Dec 27, 2018

When doing the CardExpiry salesforce export I realised we are not generating the correct bucket names for the export if the name of the salesforce object is in camelcase.
The convention for ophan data lake buckets is to use hyphen case so instead of :
ophan-raw-salesforce-cardExpiry

we should be writing to
ophan-raw-salesforce-card-expiry

@@ -6,8 +6,14 @@ import com.gu.sf_datalake_export.salesforce_bulk_api.BulkApiParams.ObjectName
import com.gu.util.config.Stage

object ExportS3Path {

def camelToHyphenCase(camelCaseString: String): String = {
val beforeUpperCase = "(?=[A-Z])"
Copy link
Contributor Author

@pvighi pvighi Dec 27, 2018

Choose a reason for hiding this comment

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

I'm not a big fan of regular expressions but I could not find a better way to do this. This matches a zero length space before an upper case letter so when we split using it the upper case letter is not removed from the resulting parts.
Also, this simple conversion is good enough for all our salesforce object names defined in: https://github.com/guardian/zuora-auto-cancel/blob/master/handlers/sf-datalake-export/src/main/scala/com/gu/sf_datalake_export/salesforce_bulk_api/SfQueries.scala#L18
but would fail for strings with multiple upperCase letters in a row like "AmazonSQSClient"

Copy link
Member

Choose a reason for hiding this comment

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

I think that's OK. For example we use Card_Expiry not CC_Expiry.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 796

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.09%) to 71.371%

Files with Coverage Reduction New Missed Lines %
handlers/sf-contact-merge/src/main/scala/com/gu/sf_contact_merge/DomainSteps.scala 1 87.76%
handlers/sf-datalake-export/src/main/scala/com/gu/sf_datalake_export/salesforce_bulk_api/CloseJob.scala 1 66.67%
src/main/scala/com/gu/stripeCustomerSourceUpdated/SourceUpdatedSteps.scala 1 77.78%
Totals Coverage Status
Change from base Build 791: 0.09%
Covered Lines: 1952
Relevant Lines: 2735

💛 - Coveralls

Copy link
Member

@paulbrown1982 paulbrown1982 left a comment

Choose a reason for hiding this comment

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

👍

@pvighi pvighi changed the title Handle salesforce object with camelcase names correctly Handle salesforce objects with camelcase names correctly Dec 27, 2018
@pvighi pvighi merged commit 0fabe26 into master Dec 28, 2018
@pvighi pvighi deleted the camelcaseObjs branch December 28, 2018 10:04
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.

None yet

3 participants