Activities with organizations#968
Conversation
…iliations into a new table
…wdDotDev/crowd.dev into feature/activities-with-organization
sausage-todd
left a comment
There was a problem hiding this comment.
Looks great, but clarify a couple comments please before we merge
|
|
||
| const currentTenant = SequelizeRepository.getCurrentTenant(options) | ||
|
|
||
| const segment = SequelizeRepository.getStrictlySingleActiveSegment(options) |
| include: [ | ||
| { | ||
| model: options.database.segment, | ||
| as: 'segments', | ||
| through: { | ||
| attributes: [], | ||
| }, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
Activities have their own segments, right? If you need segments in the returned data, why not include segments just by themselves on the top level?
There was a problem hiding this comment.
we don't need the include at all anymore, I was first keeping the affiliation settings in memberSegments then changed to a new table, this was some artifact from it. Thanks for spotting it 👍 removed the include
| UPDATE activities | ||
| SET "organizationId" = ( | ||
| SELECT mo."organizationId" | ||
| FROM "memberOrganizations" AS mo | ||
| WHERE mo."memberId" = activities."memberId" | ||
| ORDER BY mo."createdAt" DESC | ||
| LIMIT 1 | ||
| ); No newline at end of file |
There was a problem hiding this comment.
This doesn't look right. Shouldn't we also filter by tenantId, and maybe segmentId ?
There was a problem hiding this comment.
tenantId filter is already implicitly in memberId since each member can belong to only one tenant -
I didn't include segments because, in the prod data, we don't have segments yet. Tho probably it'll be better to add it for the staging data - I updated the query to also join by organizationSegments 👍
| @@ -0,0 +1 @@ | |||
| ALTER TABLE public."activities" DROP COLUMN "organizationId" No newline at end of file | |||
There was a problem hiding this comment.
DROP TABLE "memberSegmentAffiliations" ?
| export function switchSegments(options, segments) { | ||
| options.currentSegments = segments | ||
| } |
| const parent = await segmentRepository.findBySlug(data.parentSlug, SegmentLevel.PROJECT) | ||
|
|
||
| if (parent === null) { | ||
| throw new Error(`Project ${data.parentSlug} does not exist.`) | ||
| } | ||
|
|
||
| const grandparent = await segmentRepository.findBySlug( | ||
| data.grandparentSlug, | ||
| SegmentLevel.PROJECT_GROUP, | ||
| ) | ||
|
|
||
| if (grandparent === null) { | ||
| throw new Error(`Project group ${data.parentSlug} does not exist.`) | ||
| } | ||
|
|
…rs by activity segment
Changes proposed ✍️
organizationIdfield in activities.affiliationsand it has the form of:While we return this along with the member, we also include additional join attributes for segment and organization (
organizationName, organizationLogo, segmentParentName, segmentName, segmentSlug)What
🤖 Generated by Copilot at d394665
This pull request adds and improves features related to activity and member data, organization information, and conversation settings. It updates the data models, repositories, services, and scripts to handle the new and modified fields and associations. It also refactors some code to use the format method and adds a new script to the data sink worker service.
🤖 Generated by Copilot at d394665
Why
How
🤖 Generated by Copilot at d394665
sendNodeWorkerMessagefunction (link)memberEnrichmentService(link)sampleDataService(link)data_sink_workerservice (link)data_sink_workerrepo to use format method (link, link)memberRepository(link)Checklist ✅
Feature,Improvement, orBug.