11//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14
22
3+ #![ allow( clippy:: exhaustive_enums, unused_qualifications) ]
4+
35use std:: fmt:: Display ;
46
57use crate :: { HISTORY_MAX_TRIES , PUZZLE_LETTERS_COUNT , PuzzleDate , PuzzleSolution , SubmitHistory } ;
68
79use sea_orm:: entity:: prelude:: * ;
810use serde:: { Deserialize , Serialize } ;
911
12+ /// The `histories` table model.
1013#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize , DeriveEntityModel ) ]
1114#[ sea_orm( table_name = "histories" ) ]
1215pub struct Model {
16+ /// The puzzle date.
1317 #[ sea_orm( primary_key, auto_increment = false ) ]
1418 pub date : PuzzleDate ,
19+ /// The session token.
1520 #[ sea_orm( primary_key, auto_increment = false ) ]
1621 pub session : String ,
22+ /// The submit history in JSON format.
1723 #[ sea_orm( column_type = "JsonBinary" , nullable) ]
1824 pub submit_history : Option < SubmitHistory > ,
19- pub original_solution : PuzzleSolution ,
20- pub is_dirty : bool ,
25+ /// The solution submitted.
26+ pub solution : PuzzleSolution ,
27+ /// Whether the puzzle has been completed.
2128 pub is_completed : bool ,
29+ /// The timestamp when this history was uploaded.
2230 pub uploaded_at : DateTime ,
2331}
2432
2533impl Model {
34+ /// Returns the number of letters in the puzzle.
2635 pub fn letters_count ( & self ) -> usize {
2736 PUZZLE_LETTERS_COUNT
2837 }
2938
39+ /// Returns the number of remaining tries.
3040 pub fn remaining_tries ( & self ) -> usize {
3141 match & self . submit_history {
3242 Some ( submit_history) => submit_history. remaining_tries ( ) ,
@@ -39,19 +49,16 @@ impl Display for Model {
3949 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4050 write ! (
4151 f,
42- "{:?} -> {} [{} {}] {{{}}} at {}" ,
43- self . submit_history,
44- self . original_solution,
45- self . date,
46- if self . is_dirty { "*" } else { "~" } ,
47- self . session,
48- self . uploaded_at
52+ "{:?} -> {} at {} [{}] {{{}}}" ,
53+ self . submit_history, self . solution, self . uploaded_at, self . date, self . session
4954 )
5055 }
5156}
5257
58+ /// The relations of the `histories` table.
5359#[ derive( Copy , Clone , Debug , EnumIter , DeriveRelation ) ]
5460pub enum Relation {
61+ /// The relation to the `puzzles` table.
5562 #[ sea_orm(
5663 belongs_to = "super::puzzles::Entity" ,
5764 from = "Column::Date" ,
@@ -60,6 +67,7 @@ pub enum Relation {
6067 on_delete = "Cascade"
6168 ) ]
6269 Puzzles ,
70+ /// The relation to the `sessions` table.
6371 #[ sea_orm(
6472 belongs_to = "super::sessions::Entity" ,
6573 from = "Column::Session" ,
0 commit comments