rename communityEcology → board across backend

Model, schemas, API routes, activity log, and all server handlers
updated. Old ecology/ and community-ecology routes removed, new
board/ routes added. Tests updated and new board-suggestions tests
written (10 cases).
This commit is contained in:
Jennie Robinson Faber 2026-04-14 12:00:15 +01:00
parent 59d6e97787
commit 091ec58073
20 changed files with 405 additions and 80 deletions

View file

@ -22,7 +22,7 @@ export default defineEventHandler(async (event) => {
location: member.location,
socialLinks: member.socialLinks,
craftTags: member.craftTags,
communityEcology: member.communityEcology,
board: member.board,
showInDirectory: member.showInDirectory,
notifications: member.notifications,
privacy: member.privacy,

View file

@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
const member = await requireAuth(event)
const memberId = member._id
const topics = member.communityEcology?.topics || []
const topics = member.board?.topics || []
if (!topics.length) {
return { suggestions: [] }
}
@ -26,9 +26,9 @@ export default defineEventHandler(async (event) => {
const candidates = await Member.find({
_id: { $ne: memberId },
status: 'active',
'communityEcology.topics.tagSlug': { $in: mySlugs },
'board.topics.tagSlug': { $in: mySlugs },
})
.select('name avatar craftTags circle communityEcology privacy')
.select('name avatar craftTags circle board privacy')
.lean()
if (!candidates.length) {
@ -42,7 +42,7 @@ export default defineEventHandler(async (event) => {
const suggestions = []
for (const candidate of candidates) {
const theirTopics = candidate.communityEcology?.topics || []
const theirTopics = candidate.board?.topics || []
const matchingTags = []
for (const theirTopic of theirTopics) {
@ -79,8 +79,8 @@ export default defineEventHandler(async (event) => {
// Expose slackHandle only when the candidate has opted into peer support.
// Slack handle is the contact-in-place path — without it, there is no way
// for the current member to reach out.
if (candidate.communityEcology?.offerPeerSupport && candidate.communityEcology?.slackHandle) {
filtered.slackHandle = candidate.communityEcology.slackHandle
if (candidate.board?.offerPeerSupport && candidate.board?.slackHandle) {
filtered.slackHandle = candidate.board.slackHandle
}
suggestions.push({

View file

@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
// Combine craft tags and cooperative ecology tags
const craftTags = member.craftTags || []
const ecologyTags = (member.communityEcology?.topics || []).map(t => t.tagSlug)
const ecologyTags = (member.board?.topics || []).map(t => t.tagSlug)
const memberTags = [...new Set([...craftTags, ...ecologyTags].filter(Boolean))]
if (!memberTags.length) {

View file

@ -30,7 +30,7 @@ export default defineEventHandler(async (event) => {
status: "active",
})
.select(
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags communityEcology createdAt memberNumber",
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags board createdAt memberNumber",
)
.lean();
@ -70,18 +70,18 @@ export default defineEventHandler(async (event) => {
if (isVisible("socialLinks")) filtered.socialLinks = member.socialLinks;
if (isVisible("craftTags")) filtered.craftTags = member.craftTags;
if (isVisible("communityEcology")) {
const ecology = member.communityEcology || {};
filtered.communityEcology = {
topics: ecology.topics,
offerPeerSupport: ecology.offerPeerSupport,
availability: ecology.availability,
details: ecology.details,
if (isVisible("board")) {
const board = member.board || {};
filtered.board = {
topics: board.topics,
offerPeerSupport: board.offerPeerSupport,
availability: board.availability,
details: board.details,
// Contact-in-place: surface the handle + personal message only when
// the member has explicitly opted into peer support.
...(ecology.offerPeerSupport && {
slackHandle: ecology.slackHandle,
personalMessage: ecology.personalMessage,
...(board.offerPeerSupport && {
slackHandle: board.slackHandle,
personalMessage: board.personalMessage,
}),
};
}

View file

@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
const andConditions = [];
if (peerSupport === "true") {
dbQuery["communityEcology.offerPeerSupport"] = true;
dbQuery["board.offerPeerSupport"] = true;
}
if (search) {
@ -56,7 +56,7 @@ export default defineEventHandler(async (event) => {
}
if (connectionTag) {
dbQuery["communityEcology.topics.tagSlug"] = connectionTag;
dbQuery["board.topics.tagSlug"] = connectionTag;
}
if (andConditions.length > 0) {
@ -66,7 +66,7 @@ export default defineEventHandler(async (event) => {
try {
const members = await Member.find(dbQuery)
.select(
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags communityEcology createdAt",
"name pronouns timeZone avatar studio bio location socialLinks privacy circle craftTags board createdAt",
)
.sort({ createdAt: -1 })
.lean();
@ -96,14 +96,14 @@ export default defineEventHandler(async (event) => {
if (isVisible("socialLinks")) filtered.socialLinks = member.socialLinks;
if (isVisible("craftTags")) filtered.craftTags = member.craftTags;
if (isVisible("communityEcology")) {
const ecology = member.communityEcology || {};
filtered.communityEcology = {
topics: ecology.topics,
offerPeerSupport: ecology.offerPeerSupport,
availability: ecology.availability,
...(ecology.offerPeerSupport && {
slackHandle: ecology.slackHandle,
if (isVisible("board")) {
const board = member.board || {};
filtered.board = {
topics: board.topics,
offerPeerSupport: board.offerPeerSupport,
availability: board.availability,
...(board.offerPeerSupport && {
slackHandle: board.slackHandle,
}),
};
}

View file

@ -5,15 +5,15 @@ export default defineEventHandler(async (event) => {
await connectDB()
const member = await requireAuth(event)
const body = await validateBody(event, communityEcologyUpdateSchema)
const body = await validateBody(event, boardUpdateSchema)
const updateData = {
'communityEcology.topics': body.topics || [],
'communityEcology.offerPeerSupport': body.offerPeerSupport || false,
'communityEcology.availability': body.availability || '',
'communityEcology.slackHandle': body.slackHandle || '',
'communityEcology.personalMessage': body.personalMessage || '',
'communityEcology.details': body.details || '',
'board.topics': body.topics || [],
'board.offerPeerSupport': body.offerPeerSupport || false,
'board.availability': body.availability || '',
'board.slackHandle': body.slackHandle || '',
'board.personalMessage': body.personalMessage || '',
'board.details': body.details || '',
}
if (body.offerPeerSupport && body.slackHandle) {
@ -27,12 +27,12 @@ export default defineEventHandler(async (event) => {
updateData.slackUserId = slackUserId
} else {
console.warn(
`[Community Ecology] Could not find Slack user ID for handle: ${body.slackHandle}`,
`[Board] Could not find Slack user ID for handle: ${body.slackHandle}`,
)
}
}
} catch (error) {
console.error('[Community Ecology] Error fetching Slack user ID:', error.message)
console.error('[Board] Error fetching Slack user ID:', error.message)
}
}
@ -50,21 +50,21 @@ export default defineEventHandler(async (event) => {
})
}
logActivity(member._id, 'community_ecology_updated', {
logActivity(member._id, 'board_updated', {
topicCount: (body.topics || []).length,
offerPeerSupport: body.offerPeerSupport || false,
})
return {
success: true,
communityEcology: updated.communityEcology,
board: updated.board,
}
} catch (error) {
if (error.statusCode) throw error
console.error('Community ecology update error:', error)
console.error('Board update error:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to update community ecology settings',
statusMessage: 'Failed to update board settings',
})
}
})

View file

@ -32,7 +32,7 @@ export default defineEventHandler(async (event) => {
"locationPrivacy",
"socialLinksPrivacy",
"craftTagsPrivacy",
"communityEcologyPrivacy",
"boardPrivacy",
];
// Build update object from validated data

View file

@ -5,13 +5,13 @@ export default defineEventHandler(async (event) => {
const hasProfileTags =
member.craftTags.length > 0 &&
(member.communityEcology?.topics || []).length > 0
(member.board?.topics || []).length > 0
const hasVisitedEvent = !!member.onboarding?.eventPageVisited
const topics = member.communityEcology?.topics || []
const topics = member.board?.topics || []
const hasEngagedEcology =
!!member.onboarding?.ecologyPageVisited &&
!!member.onboarding?.boardPageVisited &&
topics.some((t) => ['help', 'interested', 'seeking'].includes(t.state))
const hasClickedWiki = !!member.onboarding?.wikiClicked

View file

@ -32,10 +32,10 @@ export default defineEventHandler(async (event) => {
_id: member._id,
'onboarding.completedAt': null,
'onboarding.eventPageVisited': true,
'onboarding.ecologyPageVisited': true,
'onboarding.boardPageVisited': true,
'onboarding.wikiClicked': true,
'craftTags.0': { $exists: true },
'communityEcology.topics': {
'board.topics': {
$elemMatch: { state: { $in: ['help', 'interested', 'seeking'] } },
},
},

View file

@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
// Combine craft tags and cooperative ecology tags
const craftTags = member.craftTags || []
const ecologyTags = (member.communityEcology?.topics || []).map(t => t.tagSlug)
const ecologyTags = (member.board?.topics || []).map(t => t.tagSlug)
const memberTags = [...new Set([...craftTags, ...ecologyTags].filter(Boolean))]
if (!memberTags.length) {