@@ -10,113 +10,38 @@ class RepositoryData:
1010 works : list [repository_api .Work ]
1111 readings : list [repository_api .Reading ]
1212 reviews : list [repository_api .Review ]
13- work_year_sequence_map : dict [str , int ] = field (default_factory = dict , init = False )
14- author_sequence_map : dict [str , int ] = field (default_factory = dict , init = False )
15- title_sequence_map : dict [str , int ] = field (default_factory = dict , init = False )
16- review_sequence_map : dict [str , int ] = field (default_factory = dict , init = False )
17- grade_sequence_map : dict [str , int ] = field (default_factory = dict , init = False )
18- timeline_sequence_map : dict [tuple [str , str , str ], int ] = field (default_factory = dict , init = False )
13+ review_sequence_map : dict [str , str ] = field (default_factory = dict , init = False )
14+ reading_entry_sequence_map : dict [tuple [str , str , str ], int ] = field (
15+ default_factory = dict , init = False
16+ )
1917 reading_sequence_map : dict [tuple [str , int ], int ] = field (default_factory = dict , init = False )
2018
2119 def __post_init__ (self ) -> None :
2220 """Calculate sequence maps after initialization."""
23- self .work_year_sequence_map = self ._build_work_year_sequence_map ()
24- self .author_sequence_map = self ._build_author_sequence_map ()
25- self .title_sequence_map = self ._build_title_sequence_map ()
2621 self .review_sequence_map = self ._build_review_sequence_map ()
27- self .grade_sequence_map = self ._build_grade_sequence_map ()
28- self .timeline_sequence_map = self ._build_timeline_sequence_map ()
22+ self .reading_entry_sequence_map = self ._build_reading_entry_sequence_map ()
2923 self .reading_sequence_map = self ._build_reading_sequence_map ()
3024
31- def _build_work_year_sequence_map (self ) -> dict [str , int ]:
32- """Build a mapping of work slugs to their numeric position based on year-author-title sort.
33-
34- Returns a dictionary where keys are work slugs and values are their 1-based
35- position in the sorted order of "{work.year}-{first_author_sort_name}-{work.sort_title}".
36- """
37-
38- def get_sort_key (work : repository_api .Work ) -> str :
39- first_author = work .work_authors [0 ].author (self .authors )
40- first_author_sort_name = first_author .sort_name
41- return f"{ work .year } -{ first_author_sort_name } -{ work .sort_title } "
42-
43- sorted_works = sorted (self .works , key = get_sort_key )
44- return {work .slug : idx + 1 for idx , work in enumerate (sorted_works )}
45-
46- def _build_author_sequence_map (self ) -> dict [str , int ]:
47- """Build a mapping of work slugs to their numeric position based on author-year-title sort.
48-
49- Returns a dictionary where keys are work slugs and values are their 1-based
50- position in the sorted order of "{first_author_sort_name}-{work.year}-{work.sort_title}".
51- """
52-
53- def get_sort_key (work : repository_api .Work ) -> str :
54- first_author = work .work_authors [0 ].author (self .authors )
55- first_author_sort_name = first_author .sort_name
56- return f"{ first_author_sort_name } -{ work .year } -{ work .sort_title } "
57-
58- sorted_works = sorted (self .works , key = get_sort_key )
59- return {work .slug : idx + 1 for idx , work in enumerate (sorted_works )}
60-
61- def _build_title_sequence_map (self ) -> dict [str , int ]:
62- """Build a mapping of work slugs to their numeric position based on title-author-year sort.
63-
64- Returns a dictionary where keys are work slugs and values are their 1-based
65- position in the sorted order of "{work.sort_title}-{first_author_sort_name}-{work.year}".
66- """
67-
68- def get_sort_key (work : repository_api .Work ) -> str :
69- first_author = work .work_authors [0 ].author (self .authors )
70- first_author_sort_name = first_author .sort_name
71- return f"{ work .sort_title } -{ first_author_sort_name } -{ work .year } "
72-
73- sorted_works = sorted (self .works , key = get_sort_key )
74- return {work .slug : idx + 1 for idx , work in enumerate (sorted_works )}
75-
76- def _build_review_sequence_map (self ) -> dict [str , int ]:
25+ def _build_review_sequence_map (self ) -> dict [str , str ]:
7726 """Build a mapping of work slugs to their review sequence number.
7827
7928 Returns a dictionary where keys are work slugs and values are their 1-based
8029 position in the sorted order of "{review.date}-{most_recent_reading.sequence}".
8130 """
82- review_sequences : list [tuple [str , str ]] = [] # (work_slug, sort_key)
83-
84- for review in self .reviews :
85- work = review .work (self .works )
86- readings = list (work .readings (self .readings ))
87-
88- if readings :
89- most_recent_reading = sorted (readings , key = lambda r : r .sequence , reverse = True )[0 ]
90- sort_key = f"{ review .date } -{ most_recent_reading .sequence } "
91- review_sequences .append ((work .slug , sort_key ))
92-
93- # Sort by the sort_key and create mapping
94- sorted_sequences = sorted (review_sequences , key = lambda x : x [1 ])
95- return {work_slug : idx + 1 for idx , (work_slug , _ ) in enumerate (sorted_sequences )}
96-
97- def _build_grade_sequence_map (self ) -> dict [str , int ]:
98- """Build a mapping of work slugs to their grade sequence number.
99-
100- Returns a dictionary where keys are work slugs and values are their 1-based
101- position in the sorted order of
102- "{review.grade_value}-{review.date}-{most_recent_reading.sequence}".
103- """
104- grade_sequences : list [tuple [str , str ]] = [] # (work_slug, sort_key)
31+ review_sequences : dict [str , str ] = {} # (work_slug, sort_key)
10532
10633 for review in self .reviews :
10734 work = review .work (self .works )
10835 readings = list (work .readings (self .readings ))
10936
11037 if readings :
11138 most_recent_reading = sorted (readings , key = lambda r : r .sequence , reverse = True )[0 ]
112- sort_key = f"{ review .grade_value :02d } - { review . date } -{ most_recent_reading .sequence } "
113- grade_sequences . append (( work .slug , sort_key ))
39+ sort_key = f"{ review .date } -{ most_recent_reading .sequence :02 } "
40+ review_sequences [ work .slug ] = sort_key
11441
115- # Sort by the sort_key and create mapping
116- sorted_sequences = sorted (grade_sequences , key = lambda x : x [1 ])
117- return {work_slug : idx + 1 for idx , (work_slug , _ ) in enumerate (sorted_sequences )}
42+ return review_sequences
11843
119- def _build_timeline_sequence_map (self ) -> dict [tuple [str , str , str ], int ]:
44+ def _build_reading_entry_sequence_map (self ) -> dict [tuple [str , str , str ], int ]:
12045 """Build a mapping of timeline entries to their sequence number.
12146
12247 Returns a dictionary where keys are tuples of
0 commit comments