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

feat: read from content_preference source member #2451

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

capJavert
Copy link
Contributor

@capJavert capJavert commented Nov 15, 2024

AS-681

  • read from ContentPreferenceSource instead of SourceMember
  • test updates
    • lots of changes, good thing is that none of them really failed due to logic but just difference in test setup (content preference vs source member fixtures)
    • adjust tests to use ContentPreferenceSource instead of SourceMember
    • some tests also include SourceMember due to backward compatibility (we still write to SourceMember as well)
  • triggers left as is until we completely remove SourceMember
  • all queries read from ContentPreference but fields return the same source member fields so no changes needed for frontend (see graphorm/index.ts fields changes)
  • content_preference table is now used for cdc instead of source_member (debezium config updated)

@capJavert capJavert self-assigned this Nov 15, 2024
@capJavert capJavert marked this pull request as ready for review November 18, 2024 14:19
@capJavert capJavert requested a review from a team as a code owner November 18, 2024 14:19
'hide',
)
.from(ContentPreference, 't')
.innerJoin(
Copy link
Member

Choose a reason for hiding this comment

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

anyway we can get rid of this join? i also think that somewhere we already do this join so we can reuse it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same issue as #2451 (comment)

} else if (
typeof graphorm.mappings?.SourceMember.fields?.roleRank.select ===
'string'
) {
queryBuilder = queryBuilder.andWhere(
`${graphorm.mappings.SourceMember.fields.roleRank.select} >= 0`,
);
} else if (
typeof graphorm.mappings!.SourceMember!.fields!.roleRank.select ===
Copy link
Member

Choose a reason for hiding this comment

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

What is this addition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Field is now a function in graphorm/index, before it was a string so I had to adjust it. See https://github.com/dailydotdev/daily-api/pull/2451/files#diff-928042d056cac827c70794ef59920facfe32f158ebf447ff7d2826fcad5195aeR541-R542

const sourceId =
data.payload.after!.sourceId || data.payload.before!.sourceId;

const source = await con
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should consider storing a flag that says on content preference that this is a squad? It will make fetching the source redundant and the content preference object will be complete

Copy link
Contributor Author

@capJavert capJavert Nov 28, 2024

Choose a reason for hiding this comment

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

I thought about that, initially ContentPreference had a different type for squad all together but I opted to make it source because in more places we use them interchangeably.

Adding another flag for this differentiation would solve it, but then its another field that has to be synced and set here and on source.type itself if type of source changes (it does not happen often I think, or never).

You think this would be expensive if we don't add the flag? I added additional check so its only queried for source type.

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 it's a downgrade from what we had and might make it unclear for other devs that it needs to be queried

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking, should we have gone with a route to have different type for squad content_preference then.

Copy link
Member

Choose a reason for hiding this comment

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

Since it's water under the bridge now, let's proceed as is then. We should just be clear about it and pay attention

Copy link
Member

@idoshamun idoshamun left a comment

Choose a reason for hiding this comment

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

Massive work @capJavert, way to go!!!

feat: do not show status blocked in member lists

feat: do not send notifications for status blocked members

feat: still show member is part of source if status was blocked (since new UI is missing this is temp nuances)
Copy link
Contributor Author

@capJavert capJavert left a comment

Choose a reason for hiding this comment

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

I added some missed stuff to not show blocked squads i member lists and sidebar and also to avoid sending them notifications.

const sourceId =
data.payload.after!.sourceId || data.payload.before!.sourceId;

const source = await con
Copy link
Contributor Author

@capJavert capJavert Nov 28, 2024

Choose a reason for hiding this comment

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

I thought about that, initially ContentPreference had a different type for squad all together but I opted to make it source because in more places we use them interchangeably.

Adding another flag for this differentiation would solve it, but then its another field that has to be synced and set here and on source.type itself if type of source changes (it does not happen often I think, or never).

You think this would be expensive if we don't add the flag? I added additional check so its only queried for source type.

} else if (
typeof graphorm.mappings?.SourceMember.fields?.roleRank.select ===
'string'
) {
queryBuilder = queryBuilder.andWhere(
`${graphorm.mappings.SourceMember.fields.roleRank.select} >= 0`,
);
} else if (
typeof graphorm.mappings!.SourceMember!.fields!.roleRank.select ===
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Field is now a function in graphorm/index, before it was a string so I had to adjust it. See https://github.com/dailydotdev/daily-api/pull/2451/files#diff-928042d056cac827c70794ef59920facfe32f158ebf447ff7d2826fcad5195aeR541-R542

'hide',
)
.from(ContentPreference, 't')
.innerJoin(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same issue as #2451 (comment)

@capJavert capJavert requested a review from idoshamun November 28, 2024 17:08
Comment on lines +85 to +91
const sourceMember = await con
.getRepository(ContentPreferenceSource)
.findOneBy({
referenceId: PLUS_MEMBER_SQUAD_ID,
userId: newBase.id,
status: Not(ContentPreferenceStatus.Blocked),
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rebelchris if you can sanity check test changes for plus in this file

Copy link
Contributor Author

@capJavert capJavert Nov 28, 2024

Choose a reason for hiding this comment

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

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.

2 participants