update,
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import { COL_CUSTOMERS, COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetActiveCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
||||
filter: 'status = "active"',
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: 'role = "teacher" && status = "active"',
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import { COL_CUSTOMERS, COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetBlockedCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
||||
filter: 'status = "blocked"',
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: `role = "teacher" && status = "blocked"`,
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import { COL_CUSTOMERS, COL_USER_METAS } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetPendingCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_CUSTOMERS).getList(1, 1, {
|
||||
filter: 'status = "pending"',
|
||||
const { totalItems: count } = await pb.collection(COL_USER_METAS).getList(1, 1, {
|
||||
filter: 'role = "teacher" && status = "pending"',
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `Customer`/`Customers` records using PocketBase:
|
||||
This folder contains drivers for `Customer`/`Customers`(Collection ID: pbc_108570809) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains test drivers for `Helloworld` records using PocketBase:
|
||||
This folder contains test drivers for `Helloworld`(Collection ID: pbc_123408445) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `LessonCategory`/`LessonCategories` records using PocketBase:
|
||||
This folder contains drivers for `LessonCategory`/`LessonCategories`(Collection ID: pbc_1196309394) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `LessonType`/`LessonTypes` records using PocketBase:
|
||||
This folder contains drivers for `LessonType`/`LessonTypes`(Collection ID: pbc_2328411368) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `Customer`/`Customers` records using PocketBase:
|
||||
This folder contains drivers for `Notification`/`Notifications` (Collection ID: pbc_977978967) records using PocketBase:
|
||||
|
||||
## File Structure
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
@@ -8,24 +10,66 @@ This folder contains drivers for `Customer`/`Customers` records using PocketBase
|
||||
- count (GetAllCount.tsx, GetActiveCount.tsx, GetBlockedCount.tsx, GetPendingCount.tsx)
|
||||
- misc (Helloworld.tsx)
|
||||
- delete (Delete.tsx)
|
||||
- list (GetAll.tsx)
|
||||
- list (GetAll.tsx, GetNotificationByUserId.tsx)
|
||||
|
||||
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||
|
||||
## Assumption and Requirements
|
||||
|
||||
- assume `pb` is located in `@/lib/pb`
|
||||
- no need to handle error in this function, i'll handle it in the caller
|
||||
- type information defined in `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/Customers/type.d.tsx`
|
||||
|
||||
simple template:
|
||||
## Implementation Template
|
||||
|
||||
```typescript
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_CUSTOMERS } from '@/constants';
|
||||
import { COL_NOTIFICATIONS } from '@/constants';
|
||||
import type { CreateNotificationProps } from './type.d.ts';
|
||||
|
||||
export async function createCustomer(data: CreateFormProps) {
|
||||
// ...content
|
||||
// use direct return of pb.collection (e.g. return pb.collection(xxx))
|
||||
export async function createNotification(data: CreateNotificationProps) {
|
||||
return pb.collection(COL_NOTIFICATIONS).create(data);
|
||||
}
|
||||
```
|
||||
|
||||
## Special Considerations
|
||||
|
||||
- User-specific notifications (GetNotificationByUserId.tsx)
|
||||
- Status transitions (active/pending/blocked)
|
||||
- Priority levels handling
|
||||
- Expiration dates
|
||||
- Bulk operations support
|
||||
|
||||
## Type Definitions
|
||||
|
||||
Key types to use:
|
||||
|
||||
- `NotificationStatus`: active|pending|blocked
|
||||
- `NotificationPriority`: low|medium|high
|
||||
- `CreateNotificationProps`: Required fields
|
||||
- `UpdateNotificationProps`: Partial updates
|
||||
|
||||
## Common Patterns
|
||||
|
||||
```typescript
|
||||
// Bulk creation example
|
||||
export async function createBulkNotifications(items: CreateNotificationProps[]) {
|
||||
return Promise.all(items.map(item =>
|
||||
pb.collection(COL_NOTIFICATIONS).create(item)
|
||||
));
|
||||
}
|
||||
|
||||
// Status update example
|
||||
export async function markAsRead(id: string) {
|
||||
return pb.collection(COL_NOTIFICATIONS).update(id, { status: 'read' });
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Notes
|
||||
|
||||
- Ensure indexes on: user_id, status, created_at
|
||||
- Consider pagination for large notification lists
|
||||
- Cache frequently accessed notifications
|
||||
- Batch operations for mass notifications
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
Recommended test cases:
|
||||
|
||||
- Single notification creation
|
||||
- Bulk operations
|
||||
- Status transitions
|
||||
- User-specific queries
|
||||
- Error cases (invalid data, permissions)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `QuizCRCategory`/`QuizCRCategories` records using PocketBase:
|
||||
This folder contains drivers for `QuizCRCategory`/`QuizCRCategories`(Collection ID: pbc_4061499106) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `QuizLPCategory` records using PocketBase:
|
||||
This folder contains drivers for `QuizLPCategory`(Collection ID: pbc_3639453778) records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `QuizLPQuestion` records using PocketBase:
|
||||
This folder contains drivers for `QuizLPQuestion`/`QuizLPQuestions` records using PocketBase:
|
||||
|
||||
## File Structure
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
@@ -8,27 +10,72 @@ This folder contains drivers for `QuizLPQuestion` records using PocketBase:
|
||||
- count (GetAllCount.tsx)
|
||||
- delete (Delete.tsx)
|
||||
- list (GetAll.tsx)
|
||||
- validation (validateQuestion.tsx)
|
||||
|
||||
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||
|
||||
## Assumption and Requirements
|
||||
|
||||
- assume `pb` is located in `@/lib/pb`
|
||||
- no need to handle error in this function, i'll handle it in the caller
|
||||
- type information defined in `@/db/QuizLPQuestions/type.d.tsx`
|
||||
- Quiz LP questions require special handling for:
|
||||
- Answer validation
|
||||
- Question type checking
|
||||
- Category association
|
||||
|
||||
simple template:
|
||||
## Complete Implementation Template
|
||||
|
||||
```typescript
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_QUIZ_LP_QUESTIONS } from '@/constants';
|
||||
import type { QuizLPQuestion, CreateFormProps } from './type.d.ts';
|
||||
|
||||
export async function createQuizLPQuestion(data: CreateFormProps) {
|
||||
// ...content
|
||||
// use direct return of pb.collection (e.g. return pb.collection(COL_QUIZ_LP_QUESTIONS))
|
||||
export async function createQuizLPQuestion(data: CreateFormProps): Promise<QuizLPQuestion> {
|
||||
return pb.collection(COL_QUIZ_LP_QUESTIONS).create(data);
|
||||
}
|
||||
```
|
||||
|
||||
## Question-Specific Handling
|
||||
|
||||
### Answer Validation
|
||||
|
||||
```typescript
|
||||
export function validateLPQuestionAnswer(question: QuizLPQuestion, answer: string): boolean {
|
||||
// Implement LP question specific validation
|
||||
return question.correctAnswer === answer;
|
||||
}
|
||||
```
|
||||
|
||||
### Type Definitions
|
||||
|
||||
```typescript
|
||||
interface QuizLPQuestion {
|
||||
id: string;
|
||||
question: string;
|
||||
options: string[];
|
||||
correctAnswer: string;
|
||||
categoryId: string;
|
||||
difficulty: 'easy'|'medium'|'hard';
|
||||
}
|
||||
```
|
||||
|
||||
## Common Patterns
|
||||
|
||||
```typescript
|
||||
// Get questions by category
|
||||
export async function getQuestionsByCategory(categoryId: string) {
|
||||
return pb.collection(COL_QUIZ_LP_QUESTIONS)
|
||||
.getFullList({ filter: `categoryId = "${categoryId}"` });
|
||||
}
|
||||
|
||||
// Validate before create
|
||||
export async function createValidatedQuestion(data: CreateFormProps) {
|
||||
if (!validateQuestionData(data)) throw new Error('Invalid question data');
|
||||
return createQuizLPQuestion(data);
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
- Add index on: categoryId, difficulty
|
||||
- Consider pagination for large question sets
|
||||
- Cache frequently accessed questions
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
Recommended test cases:
|
||||
|
||||
- Basic CRUD operations
|
||||
- Answer validation
|
||||
- Category filtering
|
||||
- Difficulty level queries
|
||||
- Error cases (invalid data)
|
||||
|
11
002_source/cms/src/db/Students/type.d.ts
vendored
Normal file
11
002_source/cms/src/db/Students/type.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Student type definitions
|
||||
export interface Student {
|
||||
id: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
quota: number;
|
||||
status: 'active' | 'blocked' | 'pending';
|
||||
createdAt: Date;
|
||||
}
|
15
002_source/cms/src/db/Users.old/GetAllCount.tsx
Normal file
15
002_source/cms/src/db/Users.old/GetAllCount.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
// REQ0006
|
||||
import { COL_USERS } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetAllCount(): Promise<number> {
|
||||
try {
|
||||
const result = await pb.collection(`users`).getList(1, 9999, { filter: 'email != ""' });
|
||||
const { totalItems: count } = result;
|
||||
return count;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return -99;
|
||||
}
|
||||
}
|
30
002_source/cms/src/db/Users.old/_GUIDELINES.md
Normal file
30
002_source/cms/src/db/Users.old/_GUIDELINES.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `User`/`Users` records using PocketBase:
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
- write (Update.tsx)
|
||||
- count (GetAllCount.tsx)
|
||||
- delete (Delete.tsx)
|
||||
- list (GetAll.tsx)
|
||||
|
||||
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||
|
||||
## Assumption and Requirements
|
||||
|
||||
- assume `pb` is located in `@/lib/pb`
|
||||
- no need to handle error in this function, i'll handle it in the caller
|
||||
- type information defined in `@/db/Users/type.d.tsx`
|
||||
|
||||
simple template:
|
||||
|
||||
```typescript
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_USERS } from '@/constants';
|
||||
|
||||
export async function createUser(data: CreateFormProps) {
|
||||
// ...content
|
||||
// use direct return of pb.collection (e.g. return pb.collection(xxx))
|
||||
}
|
||||
```
|
@@ -1,6 +1,8 @@
|
||||
# GUIDELINES
|
||||
|
||||
This folder contains drivers for `LessonCategory`/`LessonCategories` records using PocketBase:
|
||||
This folder contains drivers for `Vocabulary`/`Vocabularies` records using PocketBase:
|
||||
|
||||
## File Structure
|
||||
|
||||
- create (Create.tsx)
|
||||
- read (GetById.tsx)
|
||||
@@ -8,23 +10,71 @@ This folder contains drivers for `LessonCategory`/`LessonCategories` records usi
|
||||
- count (GetAllCount.tsx)
|
||||
- delete (Delete.tsx)
|
||||
- list (GetAll.tsx)
|
||||
- types (type.d.tsx)
|
||||
|
||||
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||
|
||||
## Assumption and Requirements
|
||||
|
||||
- assume `pb` is located in `@/lib/pb`
|
||||
- no need to handle error in this function, i'll handle it in the caller
|
||||
- type information defined in `@/db/LessonCategories/type.d.tsx`
|
||||
|
||||
simple template:
|
||||
## Implementation Template
|
||||
|
||||
```typescript
|
||||
import { pb } from '@/lib/pb';
|
||||
import { COL_LESSON_CATEGORIES } from '@/constants';
|
||||
import { COL_VOCABULARIES } from '@/constants';
|
||||
import type { Vocabulary, CreateVocabularyProps } from './type.d.tsx';
|
||||
|
||||
export async function createLessonCategory(data: CreateFormProps) {
|
||||
// ...content
|
||||
// use direct return of pb.collection (e.g. return pb.collection(xxx))
|
||||
export async function createVocabulary(data: CreateVocabularyProps): Promise<Vocabulary> {
|
||||
return pb.collection(COL_VOCABULARIES).create(data);
|
||||
}
|
||||
```
|
||||
|
||||
## Vocabulary-Specific Features
|
||||
|
||||
### Field Definitions
|
||||
|
||||
```typescript
|
||||
interface Vocabulary {
|
||||
term: string;
|
||||
definition: string;
|
||||
language: string;
|
||||
difficulty: 'beginner'|'intermediate'|'advanced';
|
||||
relatedTerms: string[]; // Array of vocabulary IDs
|
||||
}
|
||||
```
|
||||
|
||||
### Common Patterns
|
||||
|
||||
```typescript
|
||||
// Search by term
|
||||
export async function searchVocabularies(term: string) {
|
||||
return pb.collection(COL_VOCABULARIES)
|
||||
.getFullList({ filter: `term ~ "${term}"` });
|
||||
}
|
||||
|
||||
// Get by difficulty level
|
||||
export async function getVocabulariesByDifficulty(level: string) {
|
||||
return pb.collection(COL_VOCABULARIES)
|
||||
.getFullList({ filter: `difficulty = "${level}"` });
|
||||
}
|
||||
```
|
||||
|
||||
## Type Safety
|
||||
|
||||
```typescript
|
||||
// Recommended types to use
|
||||
type CreateVocabularyProps = Omit<Vocabulary, 'id'|'created'|'updated'>;
|
||||
type UpdateVocabularyProps = Partial<CreateVocabularyProps>;
|
||||
```
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
- Add indexes on: term, language, difficulty
|
||||
- Consider full-text search for term/definition fields
|
||||
- Cache frequently accessed vocabulary items
|
||||
- Batch operations for bulk imports
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
Recommended test cases:
|
||||
|
||||
- Basic CRUD operations
|
||||
- Term search functionality
|
||||
- Difficulty level filtering
|
||||
- Related terms validation
|
||||
- Language-specific queries
|
||||
|
Reference in New Issue
Block a user