Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

core: forward based on relations vector#6464

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
spaced4ndy wants to merge22 commits intomember-status-vector
base:member-status-vector
Choose a base branch
Loading
fromf/relations-vector-implement

Conversation

@spaced4ndy
Copy link
Contributor

No description provided.

@spaced4ndyspaced4ndy marked this pull request as ready for reviewNovember 27, 2025 14:08
@spaced4ndyspaced4ndy changed the titlecore: forward based on relations vector wipcore: forward based on relations vectorNov 27, 2025
withStore' (\db-> setEmptyVectorForGroupId db gId)`catchAllErrors` eToView
liftIO$ threadDelay' stepDelay
migrateMembers=flip catchAllErrors eToView$do
lift waitChatStartedAndActivated
Copy link
Member

Choose a reason for hiding this comment

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

it already waited before, why twice?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

it's a loop

Comment on lines +4200 to +4202
introducedRelations<- withStore'$\db-> getIntroducedRelations db gmId
introducedToRelations<- withStore'$\db-> getIntroducedToRelations db gmId
connectedRelations<- withStore'$\db-> getIntroConnectedRelations db gmId
Copy link
Member

Choose a reason for hiding this comment

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

why these are three queries and not one?

Copy link
Member

Choose a reason for hiding this comment

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

I would try to pack it all in a single query avoiding the need to read members completely, as the change is not transactional.

Copy link
Member

Choose a reason for hiding this comment

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

and we will need to make this migration anyway, so maybe we should start from it, and here use the same function just for one member.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

it's inside member lock, logic mimicks forwarding logic

getIntroducedToRelations :: DB.Connection -> GroupMemberId -> IO [(Int64, MemberRelation)]
getIntroducedToRelations db gmId =
map ((,MRIntroducedTo) . fromOnly) <$>
Copy link
Member

Choose a reason for hiding this comment

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

if you read it separately anyway, then why map here?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

to avoid additional maps later

JOIN group_members m ON m.group_member_id = i.to_group_member_id
WHERE i.re_group_member_id = ? AND i.intro_status IN (?,?,?)
|]
(gmId, GMIntroReConnected, GMIntroToConnected, GMIntroConnected)
Copy link
Member

Choose a reason for hiding this comment

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

why do they need to be two queries and not one query with OR in join?

JOIN group_members m ON m.group_member_id = i.re_group_member_id OR m.group_member_id = i.to_group_member_id

Copy link
Member

Choose a reason for hiding this comment

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

and why map with status

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

  1. because filter is also different
  2. to avoid additional maps later

Comment on lines 2722 to 2726
when (isJust sendingMemVec)$
withGroupMemberLock"xGrpMemCon, sending member" (groupMemberId' sendingMem)$do
vec<- withStore$\db-> getMemberRelationsVector db sendingMem
let vec'= setMemberRelation (indexInGroup refMem)MRConnected vec
withStore'$\db-> updateMemberRelationsVector db sendingMem vec'
Copy link
Member

Choose a reason for hiding this comment

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

this should be a function, and most likely it can be moved inside sql

Comment on lines +1149 to +1159
getMemberRelationsIndexes:: (MemberRelation->Bool)->MemberRelationsVector-> [Int64]
getMemberRelationsIndexes p (MemberRelationsVector v)= getRelationsIndexes p v
{-#INLINE getMemberRelationsIndexes #-}

setMemberRelation::Int64->MemberRelation->MemberRelationsVector->MemberRelationsVector
setMemberRelation i r (MemberRelationsVector v)=MemberRelationsVector$ setRelation i r v
{-#INLINE setMemberRelation #-}

setMemberRelations:: [(Int64,MemberRelation)]->MemberRelationsVector->MemberRelationsVector
setMemberRelations relations (MemberRelationsVector v)=MemberRelationsVector$ setRelations relations v
{-#INLINE setMemberRelations #-}
Copy link
Member

Choose a reason for hiding this comment

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

Seems unnecessary (same as newtype). If this is to encode it into JSON, I would probably just drop it from JSON entirely (via aeson options), it is not needed outside of Haskell. Also worth revising if this relation is used in all cases that load members, and if most places don't use it (which seems likely), then this should not be part of member record at all.

FROM group_members mu
WHERE mu.member_category = 'user'
AND (
mu.member_role NOT IN (CAST('admin' AS BLOB), CAST('owner' AS BLOB))
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

member_role is written as BLOB (even though it's text)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@epoberezkinepoberezkinepoberezkin left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@spaced4ndy@epoberezkin

[8]ページ先頭

©2009-2025 Movatter.jp