chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
import {
|
||||
certSlugTypeMap,
|
||||
certToIdMap,
|
||||
Certification
|
||||
} from '@freecodecamp/shared/config/certification-settings';
|
||||
import { normalizeDate } from '../../utils/normalize.js';
|
||||
|
||||
const fullStackCertificateIds = [
|
||||
certToIdMap[Certification.RespWebDesign],
|
||||
certToIdMap[Certification.JsAlgoDataStruct],
|
||||
certToIdMap[Certification.FrontEndDevLibs],
|
||||
certToIdMap[Certification.DataVis],
|
||||
certToIdMap[Certification.BackEndDevApis],
|
||||
certToIdMap[Certification.LegacyInfoSecQa]
|
||||
];
|
||||
|
||||
/**
|
||||
* Checks if the given certification slug is known.
|
||||
*
|
||||
* @param certSlug - The certification slug to check.
|
||||
* @returns True if the certification slug is known, otherwise false.
|
||||
*/
|
||||
export function isKnownCertSlug(certSlug: string): certSlug is Certification {
|
||||
return certSlug in certSlugTypeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the completion date for the full stack certification, if it exists.
|
||||
*
|
||||
* @param completedChallenges - The array of completed challenges.
|
||||
* @param completedDate - The fallback completed date.
|
||||
* @returns The latest certification date or the completed date if no certification is found.
|
||||
*/
|
||||
export function getFallbackFullStackDate(
|
||||
completedChallenges: { id: string; completedDate: Prisma.JsonValue }[],
|
||||
completedDate: Prisma.JsonValue
|
||||
): number {
|
||||
const latestCertDate = completedChallenges
|
||||
.filter(chal => fullStackCertificateIds.includes(chal.id))
|
||||
.map(chal => ({
|
||||
...chal,
|
||||
completedDate: normalizeDate(chal.completedDate)
|
||||
}))
|
||||
.sort((a, b) => b.completedDate - a.completedDate)[0]?.completedDate;
|
||||
|
||||
return latestCertDate ?? normalizeDate(completedDate);
|
||||
}
|
||||
Reference in New Issue
Block a user