-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a list of generation and a limit of 3 generations (#9)
- Adding field lastGenerationsAsc of type LastGeneration in User - Adding a method canGenerateImage in User to limit to 3 generations The list of last generation is a field populate at each generation. It automaticaly handle the wipe of the list thanks to the method addGenerationId based on the date and month of the previous generation
- Loading branch information
1 parent
19d81c7
commit 688ed1b
Showing
4 changed files
with
219 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Timestamp } from '@google-cloud/firestore'; | ||
|
||
export class LastGeneration { | ||
generationId: string; | ||
insertedTimestamp: Timestamp; | ||
|
||
public constructor(generationId: string, insertedTimestamp: Timestamp) { | ||
this.generationId = generationId; | ||
this.insertedTimestamp = insertedTimestamp; | ||
} | ||
|
||
static fromFirestoreDocument(id: any, data: any): LastGeneration { | ||
return new LastGeneration(id, data); | ||
} | ||
|
||
static fromJson(data: any): LastGeneration { | ||
return new LastGeneration(data.generationId, data.insertedTimestamp); | ||
} | ||
|
||
toFirestoreDocument(): any { | ||
return { | ||
generationId: this.generationId, | ||
insertedTimestamp: this.insertedTimestamp, | ||
}; | ||
} | ||
|
||
toJson(): any { | ||
return { | ||
generationId: this.generationId, | ||
insertedTimestamp: this.insertedTimestamp, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters