mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(api): setup experience correctly + return it if public (#65574)
This commit is contained in:
committed by
GitHub
parent
3e961fb9c4
commit
e74a3f31b5
@@ -74,6 +74,16 @@ const testUserData: Prisma.userCreateInput = {
|
||||
}
|
||||
}
|
||||
],
|
||||
experience: [
|
||||
{
|
||||
id: 'exp1',
|
||||
title: 'Software Engineer',
|
||||
company: 'Company A',
|
||||
startDate: '2020-01-01',
|
||||
endDate: '2021-01-01',
|
||||
description: 'Worked on various projects.'
|
||||
}
|
||||
],
|
||||
partiallyCompletedChallenges: [{ id: '123', completedDate: 123 }],
|
||||
completedExams: [],
|
||||
githubProfile: 'github.com/foobar',
|
||||
@@ -185,6 +195,7 @@ const publicUserData = {
|
||||
],
|
||||
completedExams: testUserData.completedExams,
|
||||
completedSurveys: [], // TODO: add surveys
|
||||
experience: testUserData.experience,
|
||||
githubProfile: testUserData.githubProfile,
|
||||
is2018DataVisCert: testUserData.is2018DataVisCert,
|
||||
is2018FullStackCert: testUserData.is2018FullStackCert, // TODO: should this be returned? The client doesn't use it at the moment.
|
||||
@@ -254,7 +265,7 @@ describe('userRoutes', () => {
|
||||
showAbout: true,
|
||||
showCerts: true,
|
||||
showDonation: true,
|
||||
showExperience: false,
|
||||
showExperience: true,
|
||||
showHeatMap: true,
|
||||
showLocation: true,
|
||||
showName: true,
|
||||
|
||||
@@ -8,12 +8,13 @@ import * as schemas from '../../schemas.js';
|
||||
import { splitUser } from '../helpers/user-utils.js';
|
||||
import {
|
||||
normalizeChallenges,
|
||||
NormalizedChallenge,
|
||||
type NormalizedChallenge,
|
||||
normalizeFlags,
|
||||
normalizeProfileUI,
|
||||
normalizeTwitter,
|
||||
normalizeBluesky,
|
||||
removeNulls
|
||||
removeNulls,
|
||||
type NoNullProperties
|
||||
} from '../../utils/normalize.js';
|
||||
import {
|
||||
Calendar,
|
||||
@@ -48,7 +49,7 @@ type RawUser = {
|
||||
name: string;
|
||||
points: number;
|
||||
portfolio: Portfolio[];
|
||||
experience: Experience[];
|
||||
experience: NoNullProperties<Experience>[];
|
||||
profileUI: ProfileUI;
|
||||
};
|
||||
|
||||
@@ -190,7 +191,7 @@ export const userPublicGetRoutes: FastifyPluginCallbackTypebox = (
|
||||
name: user.name ?? '',
|
||||
points: getPoints(progressTimestamps),
|
||||
profileUI: normalizedProfileUI,
|
||||
experience: user.experience ?? []
|
||||
experience: user.experience.map(removeNulls) ?? []
|
||||
});
|
||||
|
||||
const returnedUser = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from '@fastify/type-provider-typebox';
|
||||
import { profileUI, examResults } from '../types.js';
|
||||
import { profileUI, examResults, experience } from '../types.js';
|
||||
|
||||
export const getPublicProfile = {
|
||||
querystring: Type.Object({
|
||||
@@ -47,6 +47,7 @@ export const getPublicProfile = {
|
||||
examResults
|
||||
})
|
||||
),
|
||||
experience: Type.Array(experience),
|
||||
// TODO(Post-MVP): return completedSurveys? Presumably not, since why
|
||||
// would this need to be public.
|
||||
githubProfile: Type.Optional(Type.String()),
|
||||
|
||||
@@ -14,6 +14,7 @@ export const createResetProperties = () => ({
|
||||
completedChallenges: [], // TODO(Post-MVP): Omit this from the document? (prisma will always return [])
|
||||
completedExams: [], // TODO(Post-MVP): Omit this from the document? (prisma will always return [])
|
||||
currentChallengeId: '',
|
||||
experience: [], // TODO(Post-MVP): Omit this from the document? (prisma will always return [])
|
||||
is2018DataVisCert: false,
|
||||
is2018FullStackCert: false,
|
||||
isA2EnglishCert: false,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { pickBy, mapValues } from 'lodash-es';
|
||||
type NullToUndefined<T> = T extends null ? undefined : T;
|
||||
type NullToFalse<T> = T extends null ? false : T;
|
||||
|
||||
type NoNullProperties<T> = {
|
||||
export type NoNullProperties<T> = {
|
||||
[P in keyof T]: NullToUndefined<T[P]>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user