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

Improve performance of demo workspace #3514

Closed
FelixMalfait opened this issue Jan 17, 2024 · 4 comments · Fixed by #6201 or #6282
Closed

Improve performance of demo workspace #3514

FelixMalfait opened this issue Jan 17, 2024 · 4 comments · Fixed by #6201 or #6282
Assignees
Labels
scope: backend Issues that are affecting the backend side only type: chore

Comments

@FelixMalfait
Copy link
Member

FelixMalfait commented Jan 17, 2024

In demo workspace we are storing 1000+ image as base64 in the DB.
This slows down the database and we need to move to another solution (use a profile pic generator website and link to these urls, host our own images on S3, etc.)

@FelixMalfait
Copy link
Member Author

Step 1: useful function convert UUID to a number

import { createHash } from 'crypto';

function uuidToNumber(uuid: string, N: number): number {
  // Create a hash of the UUID
  const hash = createHash('sha256').update(uuid).digest('hex');
  
  // Convert the first 8 characters of the hash to a decimal number
  const intHash = parseInt(hash.substring(0, 8), 16);
  
  // Use modulus operation to map the hash number to the range [1, N]
  return intHash % N + 1;
}

// Example usage:
const uuid = '123e4567-e89b-12d3-a456-426614174000';
const N = 100;  // Adjust N as needed
console.log(uuidToNumber(uuid, N));

(not required, you can also do the matching without this if you prefer)

Step 2: image service

Opt1: use https://i.pravatar.cc but I'm afraid it will break, doesn't seem to be a reliable service
Opt2: store our photos in a dedicated private git repo which we simply expose with Github pages ; I'm afraid the Opt1 service will break. Repo should be named "placeholder-images". We just need ~100 photos. Can come from existing base64 set we had created or saving it from https://thispersondoesnotexist.com

Step 3: Check that image are properly displayed on demo, I remember there was a bug but I'm not sure it's still there.

@FelixMalfait
Copy link
Member Author

Ok I created the repo and exposed it through Github pages. Should be fairly simple!

Copy link
Contributor

gitstart-app bot commented May 15, 2024

Here is the GitStart Ticket for this issue: https://clients.gitstart.com/twenty/5449/tickets/TWNTY-3514

@charlesBochet
Copy link
Member

Still accurate

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in 🎯 Roadmap & Sprints Jul 12, 2024
lucasbordeau pushed a commit that referenced this issue Jul 29, 2024
…rBase64` function (#6282)

### Description

1. This PR is a continuation of a previous PR:
#6201 (review)

2. One test case was removed here:
`packages/twenty-front/src/utils/image/__tests__/getImageAbsoluteURI.test.ts`
because since we are not handling base64 images anymore, the result is
the same of the last test case. Would you rather we update the test
instead?


### Refs

- #3514
- #6201

### Demo


https://www.loom.com/share/4f32b535c77a4d418e319b095d09452c?sid=df34adf8-b013-44ef-b794-d54846f52d2d

Fixes #3514

---------

Co-authored-by: gitstart-twenty <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: backend Issues that are affecting the backend side only type: chore
Projects
Archived in project
5 participants
@FelixMalfait @charlesBochet @gitstart-twenty @CoreTeamTwenty and others