mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 12:13:31 +08:00
feat(api): api/users/get-public-profile (#54729)
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
co-authored by
Shaun Hamilton
parent
02234419a9
commit
a8f7e15dc2
@@ -9,11 +9,16 @@ import {
|
||||
import _ from 'lodash';
|
||||
|
||||
type NullToUndefined<T> = T extends null ? undefined : T;
|
||||
type NullToFalse<T> = T extends null ? false : T;
|
||||
|
||||
type NoNullProperties<T> = {
|
||||
[P in keyof T]: NullToUndefined<T[P]>;
|
||||
};
|
||||
|
||||
type DefaultToFalse<T> = {
|
||||
[P in keyof T]: NullToFalse<T[P]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Twitter handle or URL to a URL.
|
||||
*
|
||||
@@ -78,7 +83,7 @@ type NormalizedFile = {
|
||||
path?: string;
|
||||
};
|
||||
|
||||
type NormalizedChallenge = {
|
||||
export type NormalizedChallenge = {
|
||||
challengeType?: number;
|
||||
completedDate: number;
|
||||
files: NormalizedFile[];
|
||||
@@ -142,11 +147,5 @@ export const normalizeSurveys = (
|
||||
*/
|
||||
export const normalizeFlags = <T extends Record<string, boolean | null>>(
|
||||
flags: T
|
||||
): { [K in keyof T]: boolean } => {
|
||||
const out = {} as { [K in keyof T]: boolean };
|
||||
for (const key in flags) {
|
||||
const v = flags[key];
|
||||
out[key] = typeof v === 'boolean' ? v : false;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
): DefaultToFalse<T> =>
|
||||
_.mapValues(flags, flag => flag ?? false) as DefaultToFalse<T>;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export type ProgressTimestamp = number | { timestamp: number } | null;
|
||||
|
||||
export type Calendar = Record<number, 1>;
|
||||
/**
|
||||
* Converts a ProgressTimestamp array to a object with keys based on the timestamps.
|
||||
*
|
||||
@@ -8,8 +8,8 @@ export type ProgressTimestamp = number | { timestamp: number } | null;
|
||||
*/
|
||||
export const getCalendar = (
|
||||
progressTimestamps: ProgressTimestamp[] | null
|
||||
): Record<string, 1> => {
|
||||
const calendar: Record<string, 1> = {};
|
||||
): Calendar => {
|
||||
const calendar: Calendar = {};
|
||||
|
||||
progressTimestamps?.forEach(progress => {
|
||||
if (progress === null) return;
|
||||
|
||||
Reference in New Issue
Block a user