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

Profiles Send ID #274

Closed
wants to merge 11 commits into from
Closed

Profiles Send ID #274

wants to merge 11 commits into from

Conversation

beezybarg
Copy link
Collaborator

This PR Adds the send_id to the users profile, the send id represents the order in which a user signed up for an account.

  • Added new supabase tests and updated existing tests that utilize tag_search
  • Added result set for tag_search to include tag_matches, phone_matches, send_id_matches
  • Phone numbers are only matched if at least 6 digits are entered.
  • tag_search function now takes limit and offset param args so we can have pagination and limit results, currently limit is set to 5 until pagination is implemented. tag_search(query, limit, offset)

Frontend needs to be updated to handle the new resultset.

Brandon Young and others added 10 commits April 2, 2024 06:58
send_id is a numerical representation of an account based on when it was created.
- Add Migration to backfill send_id and auto-increment on new account creation.
- Update references to Name -> Send ID
- Add  PGTap unit tests for the send_id.
…pdate db models to account for this and frontend listing funs.
Copy link

supabase bot commented Apr 5, 2024

Updates to Preview Branch (profiles_send_id) ↗︎

Deployments Status Updated
Database Fri, 05 Apr 2024 15:30:01 GMT
Services Fri, 05 Apr 2024 15:30:01 GMT
APIs Fri, 05 Apr 2024 15:30:01 GMT

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Migrations Fri, 05 Apr 2024 15:30:01 GMT
Seeding Fri, 05 Apr 2024 15:30:01 GMT

❌ Migrations Error • Fri, 05 Apr 2024 15:30:01 GMT

failed to push migrations: 1

⚠️ Warning — Preview branch version (15.1.1.37) does not match production database version (15.1.0.117).


Branching Preview Branches by Supabase.
Preview Branch Database Settings ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link

github-actions bot commented Apr 5, 2024

Vercel Unique URL: https://sendapp-8187kcnzx-0xsend.vercel.app
Vercel Preview URL: sendapp-profiles-send-id-0xsend.vercel.app
Last Commit: 649b216

Copy link
Contributor

@0xBigBoss 0xBigBoss left a comment

Choose a reason for hiding this comment

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

didn't finish all of it. let's try to keep our feature PRs separated e.g. send IDs in one PR, and profile search stacked on top of it.

for sure we need to fix the referral code thing, unless you tested that it works?

Copy link
Contributor

Choose a reason for hiding this comment

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

careful with this approach of modifying already applied migrations, pretty sure staging won't get properly updated since supabase thinks it's already applied.

This would work for prod though since it hasn't been applied.

On the safe side, let's apply this in a new migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

send_id can never be null right?

Copy link
Collaborator Author

@beezybarg beezybarg Apr 5, 2024

Choose a reason for hiding this comment

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

Correct

let baseUrl = getBaseUrl()

if (!baseUrl && typeof window !== 'undefined') {
const { protocol, hostname, port } = window.location
baseUrl = `${protocol}//${hostname}${port ? `:${port}` : ''}`
}

return `${baseUrl}/?referral=${referralCode}`
return `${baseUrl}/${linkType}/${Code}`
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this break the referral tracking code? we don't have any test coverage for that, but I'm sure it does.

https://github.com/0xsend/sendapp/blob/dev/apps/next/pages/index.tsx#L25-L34


CREATE SEQUENCE profiles_send_id_seq;
SELECT setval('profiles_send_id_seq', coalesce(max(send_id), 0) + 1, false) FROM profiles;
ALTER TABLE profiles ALTER COLUMN send_id SET DEFAULT nextval('profiles_send_id_seq');
Copy link
Contributor

Choose a reason for hiding this comment

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

also make it not null. let's add an after update trigger to ensure a user can't change their send ID since users are allowed to update their profiles according to our current RLS policies.

something like this https://github.com/0xsend/sendapp/blob/dev/supabase/migrations/20230819194129_add_tags_table_rls.sql#L98-L104

@beezybarg beezybarg closed this Apr 5, 2024
@0xBigBoss 0xBigBoss deleted the profiles_send_id branch July 16, 2024 22:08
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.

3 participants