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(account): add possibility to block #73

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

sthelemann
Copy link
Contributor

Table added for blocking accounts.

Table added for blocking accounts.
@dargmuesli dargmuesli marked this pull request as ready for review October 29, 2024 13:06
Copy link
Member

@dargmuesli dargmuesli left a comment

Choose a reason for hiding this comment

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

Good work, the EXCEPT keyword is actually new to me!

In general, these changes definitely make tests necessary now, I'd say, as the complexity of all conditions grew to a point now where the overall meaning is not easily understandable at a glance anymore.

Would you fill some files in the verify folder please by adding some test INSERTs that mimic the most crucial use cases?
"A blocked B, so B's contact is not visible for A any more" as a simple example.

src/deploy/function_events_invited.sql Outdated Show resolved Hide resolved
src/deploy/function_events_invited.sql Show resolved Hide resolved
src/deploy/function_events_invited.sql Show resolved Hide resolved
src/deploy/function_events_invited.sql Outdated Show resolved Hide resolved
DECLARE
jwt_account_id UUID;
BEGIN
jwt_account_id := NULLIF(current_setting('jwt.claims.account_id', true), '')::UUID;

RETURN QUERY
SELECT invitation.event_id FROM maevsi.invitation
SELECT event_id FROM maevsi.invitation
Copy link
Member

Choose a reason for hiding this comment

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

In a few places it's necessary to keep this prefix or the column name would be ambiguous, but maybe this is not necessary here any more if you've checked it and it works without. If this function is confirmed to still be working, you can resolve this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the future I recommend short aliases like here:
SELECT i.event_id FROM maevsi.invitation i

Copy link
Member

Choose a reason for hiding this comment

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

All of maevsi's codebase tries to prevent using abbreviations if possible as each abbreviation adds to the knowledge required to build an understanding of the code. It's considered less work to read a word than to look for, remember and recall the meaning of an abbreviation, especially as this project should stay as welcoming as possible to new developers.

I see that this kind of abbreviation you suggest is often used. I just want to not have the future discussions with others about "if we use abbreviations here, why not in another place as well" that I'm sure I'll be having... So let's not use abbreviations if there is not a requirement for them. Do you see such a requirement?

invitee_count_maximum IS NULL
OR
invitee_count_maximum > (maevsi.invitee_count(id)) -- Using the function here is required as there would otherwise be infinite recursion.
)
Copy link
Member

Choose a reason for hiding this comment

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

Just fyi: changing the indentation while also having changes to the code makes it hard to read the difference for reviewers as you can see in above. The code stays mostly the same here, but there are way more green and red lines than necessary for an addition. Therefore, it's better to change formatting in a separate PR. You can resolve this comment once understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are the general formatting rules?

Copy link
Member

Choose a reason for hiding this comment

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

I aim to have our code in the same formatting as the schema file output eventually. For now, the formatting should generally be kept as is in the existing files. Reformatting can happen though of course, just in a separate PR please.

src/deploy/table_invitation_policy.sql Outdated Show resolved Hide resolved
src/deploy/table_invitation_policy.sql Outdated Show resolved Hide resolved
src/deploy/table_invitation_policy.sql Outdated Show resolved Hide resolved
src/sqitch.plan Show resolved Hide resolved
In order to make account blocking work correctly (data of a blocked account must not be visible to the blocking account and vice versa) several fixes became necessary. In addition some code formatting issues were handled.
Copy link
Member

@dargmuesli dargmuesli left a comment

Choose a reason for hiding this comment

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

Tests are missing currently, as discussed, but important for this functionality

@@ -993,8 +993,28 @@ COMMENT ON FUNCTION maevsi.events_organized() IS 'Add a function that returns al
CREATE FUNCTION maevsi.invitation_claim_array() RETURNS uuid[]
LANGUAGE plpgsql STABLE STRICT
AS $$
DECLARE
Copy link
Member

Choose a reason for hiding this comment

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

(just using this first line out of context)

Blocking must be added to the table event_category_mapping_policy:

-- TODO: condition using table maevsi.account_block to be added later

Copy link
Member

Choose a reason for hiding this comment

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

@sthelemann this still needs to be implemented

@dargmuesli dargmuesli marked this pull request as draft December 12, 2024 13:04
Test cases for account blocking are implemented in file(s) test_account_blocking.sql. Several convenience test functions are created in the new schema maevsi_test.
@sthelemann
Copy link
Contributor Author

My original intention to insert the tests into verify/table_account_block.sql didn't work. I kept running into circular dependencies when creating schema.definition.sql, so I created a new set of files test_account_blocking.sql and put them at the end of sqitch.plan. I think it is better anyway to separate (complex) test cases from a single table creation.

@dargmuesli dargmuesli marked this pull request as ready for review December 28, 2024 23:20
The policy for table event_category_mapping  has been updated and tested.
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