Skip to content

Commit b1c6269

Browse files
committed
Added the last modified date to comic books [#2448]
1 parent 67c9047 commit b1c6269

File tree

11 files changed

+106
-29
lines changed

11 files changed

+106
-29
lines changed

comixed-model/src/main/java/org/comixedproject/model/comicbooks/ComicDetail.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,21 @@ public class ComicDetail implements PublicationDetail {
314314
@Setter
315315
private Date addedDate = new Date();
316316

317+
@Column(name = "last_modified_date", updatable = true, nullable = false)
318+
@CreatedDate
319+
@JsonProperty("lastModifiedDate")
320+
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
321+
@JsonView({
322+
View.ComicListView.class,
323+
View.DuplicatePageDetail.class,
324+
View.ReadingListDetail.class,
325+
View.DeletedPageList.class
326+
})
327+
@Temporal(TemporalType.TIMESTAMP)
328+
@Getter
329+
@Setter
330+
private Date lastModifiedDate = new Date();
331+
317332
@ElementCollection
318333
@CollectionTable(name = "read_comic_books", joinColumns = @JoinColumn(name = "comic_detail_id"))
319334
@Column(name = "comixed_user_id")
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
6+
<changeSet id="003_2448_add_last_modified_date_to_comic_details.xml" author="mcpierce">
7+
<preConditions onFail="MARK_RAN">
8+
<not>
9+
<columnExists tableName="comic_details" columnName="last_modified_date"/>
10+
</not>
11+
</preConditions>
12+
13+
<addColumn tableName="comic_details">
14+
<column name="last_modified_date" type="datetime">
15+
<constraints nullable="true"/>
16+
</column>
17+
</addColumn>
18+
19+
<sql>UPDATE comic_details
20+
SET last_modified_date=NOW();</sql>
21+
22+
<addNotNullConstraint tableName="comic_details" columnName="last_modified_date"/>
23+
24+
<createIndex tableName="comic_details" indexName="comic_details_last_modified_date_idx">
25+
<column name="last_modified_date"/>
26+
</createIndex>
27+
</changeSet>
28+
</databaseChangeLog>

comixed-model/src/main/resources/db/migrations/3.0/changelog-3.0.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
<!-- v3.0 migrations -->
1919
<include file="/db/migrations/3.0/001_2178_add_missing_foreign_keys.xml"/>
2020
<include file="/db/migrations/3.0/002_2178_add_filename_to_displayable_comics_view.xml"/>
21+
<include file="/db/migrations/3.0/003_2448_add_last_modified_date_to_comic_details.xml"/>
2122

2223
</databaseChangeLog>

comixed-repositories/src/test/resources/test-database.xml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@
158158
archive_type="CBZ"
159159
sort_name="My First Comic"
160160
description="This is a comicBook book's description"
161-
added_date="2017-06-16 15:21:00"/>
161+
added_date="2017-06-16 15:21:00"
162+
last_modified_date="2017-06-16 15:21:00"/>
162163
<comic_details comic_detail_id="2001"
163164
comic_book_id="1001"
164165
comic_state="STABLE"
@@ -173,7 +174,8 @@
173174
issue_number="513"
174175
description="This is a comicBook book's description"
175176
cover_date="2017-02-28"
176-
added_date="2017-06-15 15:20:00"/>
177+
added_date="2017-06-15 15:20:00"
178+
last_modified_date="2017-06-15 15:20:00"/>
177179
<comic_details comic_detail_id="2002"
178180
comic_book_id="1002"
179181
comic_state="STABLE"
@@ -187,7 +189,8 @@
187189
issue_number="512"
188190
description="This is a comicBook book's description"
189191
cover_date="2017-01-31"
190-
added_date="2017-06-14 15:20:00"/>
192+
added_date="2017-06-14 15:20:00"
193+
last_modified_date="2017-06-14 15:20:00"/>
191194
<comic_details comic_detail_id="2003"
192195
comic_book_id="1003"
193196
comic_state="STABLE"
@@ -201,7 +204,8 @@
201204
issue_number="512"
202205
description="This is a comicBook book's description"
203206
cover_date="1965-01-31"
204-
added_date="2017-06-13 15:20:00"/>
207+
added_date="2017-06-13 15:20:00"
208+
last_modified_date="2017-06-13 15:20:00"/>
205209
<comic_details comic_detail_id="2004"
206210
comic_book_id="1004"
207211
comic_state="STABLE"
@@ -215,7 +219,8 @@
215219
issue_number="514"
216220
description="This is a comicBook book's description"
217221
cover_date="2017-03-31"
218-
added_date="2017-06-15 15:20:00"/>
222+
added_date="2017-06-15 15:20:00"
223+
last_modified_date="2017-06-15 15:20:00"/>
219224
<comic_details comic_detail_id="2005"
220225
comic_book_id="1005"
221226
comic_state="STABLE"
@@ -229,7 +234,8 @@
229234
issue_number="250"
230235
description="This is a comicBook book's description"
231236
cover_date="2016-02-28"
232-
added_date="2017-06-15 15:20:10"/>
237+
added_date="2017-06-15 15:20:10"
238+
last_modified_date="2017-06-15 15:20:10"/>
233239
<comic_details comic_detail_id="2006"
234240
comic_book_id="1006"
235241
comic_state="STABLE"
@@ -243,7 +249,8 @@
243249
issue_number="249"
244250
description="This is a comicBook book's description"
245251
cover_date="2015-02-28"
246-
added_date="2017-06-15 15:20:20"/>
252+
added_date="2017-06-15 15:20:20"
253+
last_modified_date="2017-06-15 15:20:20"/>
247254
<comic_details comic_detail_id="2010"
248255
comic_book_id="1010"
249256
comic_state="DELETED"
@@ -257,7 +264,8 @@
257264
issue_number="249"
258265
description="This is a comicBook book's description"
259266
cover_date="2015-02-28"
260-
added_date="2017-06-15 15:20:20"/>
267+
added_date="2017-06-15 15:20:20"
268+
last_modified_date="2017-06-15 15:20:20"/>
261269
<comic_details comic_detail_id="2020"
262270
comic_book_id="1020"
263271
comic_state="STABLE"
@@ -271,6 +279,7 @@
271279
issue_number="19"
272280
description="This is a comicBook book's description"
273281
added_date="2019-04-24 09:35:00"
282+
last_modified_date="2019-04-24 09:35:00"
274283
cover_date="2017-02-31"/>
275284
<comic_details comic_detail_id="2021"
276285
comic_book_id="1021"
@@ -285,7 +294,8 @@
285294
issue_number="19"
286295
description="This is a comicBook book's description"
287296
cover_date="2017-02-31"
288-
added_date="2019-04-24 09:36:00"/>
297+
added_date="2019-04-24 09:36:00"
298+
last_modified_date="2019-04-24 09:36:00"/>
289299
<comic_details comic_detail_id="3000"
290300
comic_book_id="2000"
291301
comic_state="STABLE"
@@ -299,7 +309,8 @@
299309
issue_number="19"
300310
description="This is a comicBook book's description"
301311
cover_date="2017-02-31"
302-
added_date="2019-04-24 09:36:00"/>
312+
added_date="2019-04-24 09:36:00"
313+
last_modified_date="2019-04-24 09:36:00"/>
303314
<comic_tags comic_detail_id="2000"
304315
tag_type="CHARACTER"
305316
tag_value="Captain America"/>

comixed-services/src/main/java/org/comixedproject/service/comicbooks/ComicBookService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,14 @@ public ComicBook save(final ComicBook comicBook) {
193193
log.trace("Updating the imprint");
194194
this.imprintService.update(comicBook);
195195

196-
log.trace("Standardizing the comic filename");
197196
final ComicDetail detail = comicBook.getComicDetail();
197+
198+
log.trace("Standardizing the comic filename");
198199
detail.setFilename(comicFileAdaptor.standardizeFilename(detail.getFilename()));
199200

201+
log.trace("Setting last modified date");
202+
detail.setLastModifiedDate(new Date());
203+
200204
return this.comicBookRepository.saveAndFlush(comicBook);
201205
}
202206

comixed-services/src/test/java/org/comixedproject/service/comicbooks/ComicBookServiceTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@
5050
import org.junit.jupiter.api.BeforeEach;
5151
import org.junit.jupiter.api.Test;
5252
import org.junit.jupiter.api.extension.ExtendWith;
53-
import org.mockito.ArgumentCaptor;
54-
import org.mockito.Captor;
55-
import org.mockito.InjectMocks;
56-
import org.mockito.Mock;
57-
import org.mockito.Mockito;
53+
import org.mockito.*;
5854
import org.mockito.junit.jupiter.MockitoExtension;
5955
import org.mockito.junit.jupiter.MockitoSettings;
6056
import org.mockito.quality.Strictness;
@@ -140,6 +136,8 @@ class ComicBookServiceTest {
140136
@Captor private ArgumentCaptor<PageRequest> pageRequestCaptor;
141137
@Captor private ArgumentCaptor<Limit> previousComicBookLimitArgumentCaptor;
142138
@Captor private ArgumentCaptor<Limit> nextComicBookLimitArgumentCaptor;
139+
@Captor private ArgumentCaptor<Date> dateArgumentCaptor;
140+
143141
private Set<String> comicFilenameList = new HashSet<>();
144142

145143
@BeforeEach
@@ -374,6 +372,7 @@ void updateComic() throws ComicBookException {
374372

375373
@Test
376374
void save() {
375+
Mockito.doNothing().when(comicDetail).setLastModifiedDate(dateArgumentCaptor.capture());
377376
Mockito.when(comicBookRepository.saveAndFlush(Mockito.any(ComicBook.class)))
378377
.thenReturn(savedComicBook);
379378

@@ -382,7 +381,11 @@ void save() {
382381
assertNotNull(result);
383382
assertSame(savedComicBook, result);
384383

384+
final Date lastModifiedDate = dateArgumentCaptor.getValue();
385+
assertNotNull(lastModifiedDate);
386+
385387
Mockito.verify(comicFileAdaptor, Mockito.times(1)).standardizeFilename(TEST_COMIC_FILENAME);
388+
Mockito.verify(comicDetail, Mockito.times(1)).setLastModifiedDate(lastModifiedDate);
386389
Mockito.verify(comicBookRepository, Mockito.times(1)).saveAndFlush(comicBook);
387390
}
388391

comixed-webui/src/app/comic-books/comic-books.fixtures.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export const COMIC_DETAIL_1: ComicDetail = {
199199
storeDate: new Date().getTime(),
200200
publishedYear: 2019,
201201
publishedMonth: 3,
202-
addedDate: new Date().getTime()
202+
addedDate: new Date().getTime(),
203+
lastModifiedDate: new Date().getTime()
203204
};
204205

205206
export const COMIC_DETAIL_2: ComicDetail = {
@@ -229,7 +230,8 @@ export const COMIC_DETAIL_2: ComicDetail = {
229230
storeDate: new Date().getTime(),
230231
publishedYear: 2018,
231232
publishedMonth: 3,
232-
addedDate: new Date().getTime()
233+
addedDate: new Date().getTime(),
234+
lastModifiedDate: new Date().getTime()
233235
};
234236

235237
export const COMIC_DETAIL_3: ComicDetail = {
@@ -259,7 +261,8 @@ export const COMIC_DETAIL_3: ComicDetail = {
259261
storeDate: new Date().getTime(),
260262
publishedYear: 1953,
261263
publishedMonth: 3,
262-
addedDate: new Date().getTime()
264+
addedDate: new Date().getTime(),
265+
lastModifiedDate: new Date().getTime()
263266
};
264267

265268
export const COMIC_DETAIL_4: ComicDetail = {
@@ -289,7 +292,8 @@ export const COMIC_DETAIL_4: ComicDetail = {
289292
storeDate: new Date().getTime(),
290293
publishedYear: 1972,
291294
publishedMonth: 3,
292-
addedDate: new Date().getTime()
295+
addedDate: new Date().getTime(),
296+
lastModifiedDate: new Date().getTime()
293297
};
294298

295299
export const COMIC_DETAIL_5: ComicDetail = {
@@ -321,7 +325,8 @@ export const COMIC_DETAIL_5: ComicDetail = {
321325
storeDate: new Date().getTime(),
322326
publishedYear: 2000,
323327
publishedMonth: 3,
324-
addedDate: new Date().getTime()
328+
addedDate: new Date().getTime(),
329+
lastModifiedDate: new Date().getTime()
325330
};
326331

327332
export const COMIC_BOOK_1: ComicBook = {

comixed-webui/src/app/comic-books/components/comic-detail-edit/comic-detail-edit.component.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,14 @@
120120
</mat-form-field>
121121

122122
<mat-form-field appearance="fill" class="cx-width-25">
123-
<mat-label>{{ "comic-book.label.filesize" | translate }}</mat-label>
124-
<input matInput formControlName="fileSize" readonly />
123+
<mat-label>
124+
{{ "comic-book.label.last-modified-date" | translate }}
125+
</mat-label>
126+
<input
127+
matInput
128+
[value]="comicBook.detail.lastModifiedDate | date: 'medium'"
129+
readonly
130+
/>
125131
</mat-form-field>
126132

127133
<mat-form-field appearance="fill" class="cx-width-25">

comixed-webui/src/app/comic-books/components/comic-detail-edit/comic-detail-edit.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import { ComicBook } from '@app/comic-books/models/comic-book';
2121
import { ComicState } from '@app/comic-books/models/comic-state';
2222
import { LoggerService } from '@angular-ru/cdk/logger';
2323
import {
24+
ReactiveFormsModule,
2425
UntypedFormBuilder,
2526
UntypedFormGroup,
26-
Validators,
27-
ReactiveFormsModule
27+
Validators
2828
} from '@angular/forms';
2929
import { ConfirmationService } from '@tragically-slick/confirmation';
30-
import { TranslateService, TranslateModule } from '@ngx-translate/core';
30+
import { TranslateModule, TranslateService } from '@ngx-translate/core';
3131
import { Store } from '@ngrx/store';
3232
import { updateComicBook } from '@app/comic-books/actions/comic-book.actions';
3333
import { ComicDetail } from '@app/comic-books/models/comic-detail';
@@ -50,18 +50,20 @@ import {
5050
MatSuffix
5151
} from '@angular/material/form-field';
5252
import { MatInput } from '@angular/material/input';
53-
import { MatSelect, MatOption } from '@angular/material/select';
53+
import { MatOption, MatSelect } from '@angular/material/select';
5454
import {
55+
MatDatepicker,
5556
MatDatepickerInput,
56-
MatDatepickerToggle,
57-
MatDatepicker
57+
MatDatepickerToggle
5858
} from '@angular/material/datepicker';
59+
import { CommonModule } from '@angular/common';
5960

6061
@Component({
6162
selector: 'cx-comic-detail-edit',
6263
templateUrl: './comic-detail-edit.component.html',
6364
styleUrls: ['./comic-detail-edit.component.scss'],
6465
imports: [
66+
CommonModule,
6567
MatToolbar,
6668
MatIconButton,
6769
MatTooltip,

comixed-webui/src/app/comic-books/models/comic-detail.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ export interface ComicDetail {
4949
publishedMonth: number;
5050
storeDate: number;
5151
addedDate: number;
52+
lastModifiedDate: number;
5253
}

0 commit comments

Comments
 (0)