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) {

View file

@ -17,7 +17,7 @@ const ACTIVITY_TYPES = [
'slack_invited',
'email_sent',
'community_connections_updated',
'community_ecology_updated',
'board_updated',
'connection_requested',
'connection_confirmed',
'tag_suggested'

View file

@ -72,7 +72,7 @@ const memberSchema = new mongoose.Schema({
showInDirectory: { type: Boolean, default: true },
craftTags: [String],
communityEcology: {
board: {
topics: [
{
tagSlug: String,
@ -128,7 +128,7 @@ const memberSchema = new mongoose.Schema({
enum: ["public", "members", "private"],
default: "members",
},
communityEcology: {
board: {
type: String,
enum: ["public", "members", "private"],
default: "members",
@ -155,7 +155,7 @@ const memberSchema = new mongoose.Schema({
onboarding: {
completedAt: { type: Date, default: null },
eventPageVisited: { type: Boolean, default: false },
ecologyPageVisited: { type: Boolean, default: false },
boardPageVisited: { type: Boolean, default: false },
wikiClicked: { type: Boolean, default: false },
},

View file

@ -17,7 +17,7 @@ export const ACTIVITY_TYPES = {
SLACK_INVITED: 'slack_invited',
EMAIL_SENT: 'email_sent',
COMMUNITY_CONNECTIONS_UPDATED: 'community_connections_updated',
COMMUNITY_ECOLOGY_UPDATED: 'community_ecology_updated',
BOARD_UPDATED: 'board_updated',
CONNECTION_REQUESTED: 'connection_requested',
CONNECTION_CONFIRMED: 'connection_confirmed',
TAG_SUGGESTED: 'tag_suggested'
@ -40,7 +40,7 @@ export const ACTIVITY_TYPE_DEFAULTS = {
slack_invited: 'admin',
email_sent: 'member',
community_connections_updated: 'member',
community_ecology_updated: 'member',
board_updated: 'member',
connection_requested: 'member',
connection_confirmed: 'member',
tag_suggested: 'member'

View file

@ -41,7 +41,7 @@ export const memberProfileUpdateSchema = z.object({
socialLinksPrivacy: privacyEnum.optional(),
craftTags: z.array(z.string().max(100)).max(16).optional(),
craftTagsPrivacy: privacyEnum.optional(),
communityEcologyPrivacy: privacyEnum.optional()
boardPrivacy: privacyEnum.optional()
})
export const eventRegistrationSchema = z.object({
@ -367,7 +367,7 @@ export const inviteAcceptSchema = z.object({
// --- Onboarding schemas ---
export const onboardingTrackSchema = z.object({
goal: z.enum(['eventPageVisited', 'ecologyPageVisited', 'wikiClicked'])
goal: z.enum(['eventPageVisited', 'boardPageVisited', 'wikiClicked'])
})
// --- Tag schemas ---
@ -377,7 +377,7 @@ export const tagSuggestionSchema = z.object({
pool: z.enum(['craft', 'cooperative'])
})
export const communityEcologyUpdateSchema = z.object({
export const boardUpdateSchema = z.object({
topics: z.array(z.object({
tagSlug: z.string().min(1).max(100),
state: z.enum(['help', 'interested', 'seeking'])