Skip to content

Commit f908548

Browse files
moT01ojeytonwilliamsShaunSHamilton
authored
feat(api): add endpoint for submitting daily coding challenges (freeCodeCamp#59465)
Co-authored-by: Oliver Eyton-Williams <[email protected]> Co-authored-by: Shaun Hamilton <[email protected]>
1 parent 40f8951 commit f908548

File tree

9 files changed

+480
-66
lines changed

9 files changed

+480
-66
lines changed

api/prisma/schema.prisma

Lines changed: 79 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ type CompletedChallenge {
2929
examResults ExamResults? // Undefined
3030
}
3131

32+
enum DailyCodingChallengeLanguage {
33+
javascript
34+
python
35+
}
36+
37+
type CompletedDailyCodingChallenge {
38+
id String @db.ObjectId
39+
/// Date in milliseconds since epoch
40+
/// This is not a DateTime, because DateTime does not serialize directly to JSON
41+
completedDate Int
42+
languages DailyCodingChallengeLanguage[]
43+
}
44+
3245
type PartiallyCompletedChallenge {
3346
id String
3447
completedDate Float
@@ -77,77 +90,78 @@ type QuizAttempt {
7790

7891
/// Corresponds to the `user` collection.
7992
model user {
80-
id String @id @default(auto()) @map("_id") @db.ObjectId
81-
about String
82-
acceptedPrivacyTerms Boolean
83-
completedChallenges CompletedChallenge[]
84-
completedExams CompletedExam[] // Undefined
85-
quizAttempts QuizAttempt[] // Undefined
86-
currentChallengeId String?
87-
donationEmails String[] // Undefined | String[] (only possible for built in Types like String)
88-
email String
89-
emailAuthLinkTTL DateTime? // Null | Undefined
90-
emailVerified Boolean
91-
emailVerifyTTL DateTime? // Null | Undefined
92-
externalId String
93-
githubProfile String? // Undefined
94-
isApisMicroservicesCert Boolean? // Undefined
95-
isBackEndCert Boolean? // Undefined
96-
isBanned Boolean? // Undefined
97-
isCheater Boolean? // Undefined
98-
isDataAnalysisPyCertV7 Boolean? // Undefined
99-
isDataVisCert Boolean? // Undefined
100-
isDonating Boolean
101-
isFoundationalCSharpCertV8 Boolean? // Undefined
102-
isFrontEndCert Boolean? // Undefined
103-
isFrontEndLibsCert Boolean? // Undefined
104-
isFullStackCert Boolean? // Undefined
105-
isHonest Boolean?
106-
isInfosecCertV7 Boolean? // Undefined
107-
isInfosecQaCert Boolean? // Undefined
108-
isJsAlgoDataStructCert Boolean? // Undefined
109-
isJsAlgoDataStructCertV8 Boolean? // Undefined
110-
isMachineLearningPyCertV7 Boolean? // Undefined
111-
isQaCertV7 Boolean? // Undefined
112-
isRelationalDatabaseCertV8 Boolean? // Undefined
113-
isRespWebDesignCert Boolean? // Undefined
114-
isSciCompPyCertV7 Boolean? // Undefined
115-
is2018DataVisCert Boolean? // Undefined
116-
is2018FullStackCert Boolean? // Undefined
117-
isCollegeAlgebraPyCertV8 Boolean? // Undefined
118-
// isUpcomingPythonCertV8 Boolean? // Undefined. It is in the db but has never been used.
119-
keyboardShortcuts Boolean? // Undefined
120-
linkedin String? // Null | Undefined
121-
location String? // Null
122-
name String? // Null
123-
needsModeration Boolean? // Undefined
124-
newEmail String? // Null | Undefined
125-
partiallyCompletedChallenges PartiallyCompletedChallenge[] // Undefined | PartiallyCompletedChallenge[]
126-
password String? // Undefined
127-
picture String
128-
portfolio Portfolio[]
129-
profileUI ProfileUI? // Undefined
130-
progressTimestamps Json? // ProgressTimestamp[] | Null[] | Int64[] | Double[] - TODO: NORMALIZE
93+
id String @id @default(auto()) @map("_id") @db.ObjectId
94+
about String
95+
acceptedPrivacyTerms Boolean
96+
completedChallenges CompletedChallenge[]
97+
completedDailyCodingChallenges CompletedDailyCodingChallenge[]
98+
completedExams CompletedExam[] // Undefined
99+
quizAttempts QuizAttempt[] // Undefined
100+
currentChallengeId String?
101+
donationEmails String[] // Undefined | String[] (only possible for built in Types like String)
102+
email String
103+
emailAuthLinkTTL DateTime? // Null | Undefined
104+
emailVerified Boolean
105+
emailVerifyTTL DateTime? // Null | Undefined
106+
externalId String
107+
githubProfile String? // Undefined
108+
isApisMicroservicesCert Boolean? // Undefined
109+
isBackEndCert Boolean? // Undefined
110+
isBanned Boolean? // Undefined
111+
isCheater Boolean? // Undefined
112+
isDataAnalysisPyCertV7 Boolean? // Undefined
113+
isDataVisCert Boolean? // Undefined
114+
isDonating Boolean
115+
isFoundationalCSharpCertV8 Boolean? // Undefined
116+
isFrontEndCert Boolean? // Undefined
117+
isFrontEndLibsCert Boolean? // Undefined
118+
isFullStackCert Boolean? // Undefined
119+
isHonest Boolean?
120+
isInfosecCertV7 Boolean? // Undefined
121+
isInfosecQaCert Boolean? // Undefined
122+
isJsAlgoDataStructCert Boolean? // Undefined
123+
isJsAlgoDataStructCertV8 Boolean? // Undefined
124+
isMachineLearningPyCertV7 Boolean? // Undefined
125+
isQaCertV7 Boolean? // Undefined
126+
isRelationalDatabaseCertV8 Boolean? // Undefined
127+
isRespWebDesignCert Boolean? // Undefined
128+
isSciCompPyCertV7 Boolean? // Undefined
129+
is2018DataVisCert Boolean? // Undefined
130+
is2018FullStackCert Boolean? // Undefined
131+
isCollegeAlgebraPyCertV8 Boolean? // Undefined
132+
// isUpcomingPythonCertV8 Boolean? // Undefined. It is in the db but has never been used.
133+
keyboardShortcuts Boolean? // Undefined
134+
linkedin String? // Null | Undefined
135+
location String? // Null
136+
name String? // Null
137+
needsModeration Boolean? // Undefined
138+
newEmail String? // Null | Undefined
139+
partiallyCompletedChallenges PartiallyCompletedChallenge[] // Undefined | PartiallyCompletedChallenge[]
140+
password String? // Undefined
141+
picture String
142+
portfolio Portfolio[]
143+
profileUI ProfileUI? // Undefined
144+
progressTimestamps Json? // ProgressTimestamp[] | Null[] | Int64[] | Double[] - TODO: NORMALIZE
131145
/// A random number between 0 and 1.
132146
///
133147
/// Valuable for selectively performing random logic.
134-
rand Float?
135-
savedChallenges SavedChallenge[] // Undefined | SavedChallenge[]
136-
sendQuincyEmail Boolean
137-
theme String? // Undefined
138-
timezone String? // Undefined
139-
twitter String? // Null | Undefined
140-
unsubscribeId String
148+
rand Float?
149+
savedChallenges SavedChallenge[] // Undefined | SavedChallenge[]
150+
sendQuincyEmail Boolean
151+
theme String? // Undefined
152+
timezone String? // Undefined
153+
twitter String? // Null | Undefined
154+
unsubscribeId String
141155
/// Used to track the number of times the user's record was written to.
142156
///
143157
/// This has the main benefit of allowing concurrent ops to check for race conditions.
144-
updateCount Int? @default(0)
145-
username String // TODO(Post-MVP): make this unique
146-
usernameDisplay String? // Undefined
147-
verificationToken String? // Undefined
148-
website String? // Undefined
149-
yearsTopContributor String[] // Undefined | String[]
150-
isClassroomAccount Boolean? // Undefined
158+
updateCount Int? @default(0)
159+
username String // TODO(Post-MVP): make this unique
160+
usernameDisplay String? // Undefined
161+
verificationToken String? // Undefined
162+
website String? // Undefined
163+
yearsTopContributor String[] // Undefined | String[]
164+
isClassroomAccount Boolean? // Undefined
151165
152166
// Relations
153167
examAttempts EnvExamAttempt[]

api/src/plugins/__fixtures__/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const newUser = (email: string) => ({
1111
about: '',
1212
acceptedPrivacyTerms: false,
1313
completedChallenges: [],
14+
completedDailyCodingChallenges: [],
1415
completedExams: [],
1516
quizAttempts: [],
1617
currentChallengeId: '',

0 commit comments

Comments
 (0)