@@ -2,7 +2,10 @@ use crate::controllers::api::comic::editor_data::fetch_editor_data_for_comic;
22use crate :: controllers:: api:: comic:: navigation_data:: {
33 fetch_all_item_navigation_data, fetch_comic_item_navigation_data,
44} ;
5- use crate :: models:: { Comic , ComicId , Exclusion , Inclusion , ItemColor , ItemType } ;
5+ use crate :: models:: {
6+ Comic , ComicData , ComicId , Exclusion , False , Inclusion , ItemColor , ItemType , MissingComic ,
7+ PresentComic , True ,
8+ } ;
69use crate :: util:: NewsUpdater ;
710use actix_web:: { error, web, HttpResponse , Result } ;
811use actix_web_grants:: permissions:: { AuthDetails , PermissionsCheck } ;
@@ -129,60 +132,42 @@ pub(crate) async fn by_id(
129132 let comic = if let Some ( comic) = comic {
130133 Comic {
131134 comic : comic_id,
132- has_data : true ,
133- image_type : Some ( comic. image_type . into ( ) ) ,
134- publish_date : comic. publish_date . map ( |nd| Utc . from_utc_datetime ( & nd) ) ,
135- is_accurate_publish_date : comic. is_accurate_publish_date != 0 ,
136- title : Some ( comic. title ) ,
137- tagline : comic. tagline ,
138- is_guest_comic : comic. is_guest_comic != 0 ,
139- is_non_canon : comic. is_non_canon != 0 ,
140- has_no_cast : comic. has_no_cast != 0 ,
141- has_no_location : comic. has_no_location != 0 ,
142- has_no_storyline : comic. has_no_storyline != 0 ,
143- has_no_title : comic. has_no_title != 0 ,
144- has_no_tagline : comic. has_no_tagline != 0 ,
145- news : news. map ( |n| n. news ) ,
146- previous : previous
147- . map ( TryInto :: try_into)
148- . transpose ( )
149- . expect ( "database has valid comicIds" ) ,
150- next : next
151- . map ( TryInto :: try_into)
152- . transpose ( )
153- . expect ( "database has valid comicIds" ) ,
154135 editor_data,
155- items : comic_navigation_items,
156136 all_items : all_navigation_items,
137+ data : ComicData :: PresentComic ( PresentComic {
138+ has_data : True :: default ( ) ,
139+ image_type : Some ( comic. image_type . into ( ) ) ,
140+ publish_date : comic. publish_date . map ( |nd| Utc . from_utc_datetime ( & nd) ) ,
141+ is_accurate_publish_date : comic. is_accurate_publish_date != 0 ,
142+ title : Some ( comic. title ) ,
143+ tagline : comic. tagline ,
144+ is_guest_comic : comic. is_guest_comic != 0 ,
145+ is_non_canon : comic. is_non_canon != 0 ,
146+ has_no_cast : comic. has_no_cast != 0 ,
147+ has_no_location : comic. has_no_location != 0 ,
148+ has_no_storyline : comic. has_no_storyline != 0 ,
149+ has_no_title : comic. has_no_title != 0 ,
150+ has_no_tagline : comic. has_no_tagline != 0 ,
151+ news : news. map ( |n| n. news ) ,
152+ previous : previous
153+ . map ( TryInto :: try_into)
154+ . transpose ( )
155+ . expect ( "database has valid comicIds" ) ,
156+ next : next
157+ . map ( TryInto :: try_into)
158+ . transpose ( )
159+ . expect ( "database has valid comicIds" ) ,
160+ items : comic_navigation_items,
161+ } ) ,
157162 }
158163 } else {
159164 Comic {
160165 comic : comic_id,
161- has_data : false ,
162- image_type : None ,
163- publish_date : None ,
164- is_accurate_publish_date : false ,
165- title : None ,
166- tagline : None ,
167- is_guest_comic : false ,
168- is_non_canon : false ,
169- has_no_cast : false ,
170- has_no_location : false ,
171- has_no_storyline : false ,
172- has_no_title : false ,
173- has_no_tagline : false ,
174- news : None ,
175- previous : previous
176- . map ( TryInto :: try_into)
177- . transpose ( )
178- . expect ( "database has valid comicIds" ) ,
179- next : next
180- . map ( TryInto :: try_into)
181- . transpose ( )
182- . expect ( "database has valid comicIds" ) ,
183166 editor_data,
184- items : comic_navigation_items,
185167 all_items : all_navigation_items,
168+ data : ComicData :: Missing ( MissingComic {
169+ has_data : False :: default ( ) ,
170+ } ) ,
186171 }
187172 } ;
188173
0 commit comments