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

5425 - Introducing support for all Composite Fields Import #5470

Merged

Conversation

zaryanz
Copy link
Contributor

@zaryanz zaryanz commented May 20, 2024

Adding support for all Composite Fields while using the "import" functionality. This includes:

  • Currency
  • Address

Edit :

  • Refactored a lot of types in the spreadsheet import module
  • Renamed a lot of functions, hooks and types that were not self-explanatory enough

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Pull Request Summary

  • Introduced support for importing currency fields in the spreadsheet import functionality.
  • Added logic to handle 'Currency' field types, including template fields for 'Currency Code' and 'Amount Micros'.
  • Enhanced data import capabilities, particularly for financial data.

Notes

  • This change improves the comprehensiveness of data imports, especially for financial records.

isDefined(
record[`${amountMicros} (${field.name})`] ||
record[`${currencyCode} (${field.name})`],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

The condition isDefined(record[${amountMicros} (${field.name})] || record[${currencyCode} (${field.name})]) should be simplified to isDefined(record[${amountMicros} (${field.name})]) || isDefined(record[${currencyCode} (${field.name})]) for better readability and correctness.

@zaryanz zaryanz changed the title 5425 Introducing support for all Composite Fields Import 5425 WIP - Introducing support for all Composite Fields Import May 20, 2024
@zaryanz
Copy link
Contributor Author

zaryanz commented May 20, 2024

@charlesBochet Hi! An observation while importing data using a spreadsheet:
$1,000,000 is being saved as $1 after submitting and anything less than $1,000,000 is being saved as $0. Is this an existing issue that we are aware of or should we raise an issue for the same?
Screenshot 2024-05-20 at 3 43 59 PM
Screenshot 2024-05-20 at 3 43 23 PM

@FelixMalfait
Copy link
Member

Thanks @zaryanz! yes it's a best practise to store amounts in "micros" when dealing with currencies since database tend to be flaky with floats - but that's a database stuff that shouldn't be exposed to non-technical users that try to import via csv, so it would be great if you could make sure to automatically convert it by multiplying by 10^6. Thanks!

@zaryanz
Copy link
Contributor Author

zaryanz commented May 20, 2024

Thanks @FelixMalfait for pointing that out! Silly of me to overlook the "micros" part. Could you also please point me to the different Composite Fields for "Address"? As I couldn't mind any information on that in the issue.

@FelixMalfait
Copy link
Member

FelixMalfait commented May 20, 2024

Sure!

Linked issue: #5425

Address field: https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/metadata-modules/field-metadata/composite-types/address.composite-type.ts

Add it as a custom field type on an object to make sure it works :). It's not provisioned in any standard object for now

@zaryanz zaryanz changed the title 5425 WIP - Introducing support for all Composite Fields Import 5425 - Introducing support for all Composite Fields Import May 21, 2024
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the help! I have left comments on the PR

@@ -80,6 +95,46 @@ export const useSpreadsheetRecordImport = (objectNameSingular: string) => {
field.label + ' (ID)',
),
});
} else if (field.type === FieldMetadataType.Currency) {
templateFields.push({
Copy link
Member

Choose a reason for hiding this comment

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

can we extract the templateFields array build to an util?
I'm also not a big fan of templateFields naming. I would say availableFields

Once extracted to an util, could you also add unit tests?

@@ -108,22 +163,89 @@ export const useSpreadsheetRecordImport = (objectNameSingular: string) => {
for (const field of fields) {
Copy link
Member

Choose a reason for hiding this comment

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

can we also extract this whole logic to an util and add unit tests?

@zaryanz
Copy link
Contributor Author

zaryanz commented May 30, 2024

Thanks for the comments! I'll have a look and make the required changes

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Added support for importing all composite fields, including Currency and Address.
  • Updated ESLint rules to enforce the use of <Link> components over navigate functions.
  • Refactored Chrome extension to handle cookies, side panel behavior, and removed OAuth-related code.
  • Deleted extensive documentation files and related configurations, indicating a shift in documentation strategy.
  • Introduced new components and utilities for email templates and frontend skeleton loaders.

246 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@zaryanz
Copy link
Contributor Author

zaryanz commented Jun 27, 2024

Hey! Sorry for the delay here.. been too occupied.
Will work on the review comments this weekend. Thanks for the patience.

Copy link

github-actions bot commented Jul 23, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 3087:64B40:3019E42:5951264:669FD443.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Azaryanz%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Tue, 23 Jul 2024 16:03:15 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'3087:64B40:3019E42:5951264:669FD443'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1721750655'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 3087:64B40:3019E42:5951264:669FD443.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Azaryanz%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.4 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-4476b3b4.json

Generated by 🚫 dangerJS against 0804cc5

@lucasbordeau lucasbordeau merged commit 5c8fe02 into twentyhq:main Jul 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants