Skip to content

Commit

Permalink
Changed ComicVineId to be a number [#1046]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Oct 22, 2021
1 parent fbbc239 commit 5bf8feb
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 47 deletions.
Expand Up @@ -29,7 +29,7 @@ public class ComicDataAdaptor {
* @param comic the comic
*/
public void clear(Comic comic) {
comic.setComicVineId("");
comic.setComicVineId(null);
comic.setPublisher("");
comic.setSeries("");
comic.setVolume("");
Expand Down
Expand Up @@ -368,12 +368,12 @@ public class Comic {
@Setter
private Date lastModifiedOn = new Date();

@Column(name = "ComicVineId", length = 16)
@Column(name = "ComicVineId")
@JsonProperty("comicVineId")
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String comicVineId;
private Integer comicVineId;

@Column(name = "SortName", length = 128)
@JsonProperty("sortName")
Expand Down
Expand Up @@ -54,12 +54,12 @@ public class Story {
@NonNull
private String name;

@Column(name = "ComicVineId", length = 16, nullable = true, updatable = true, unique = true)
@Column(name = "ComicVineId", nullable = true, updatable = true, unique = true)
@JsonProperty("comicVineId")
@JsonView(View.StoryList.class)
@Getter
@Setter
private String comicVineId;
private Integer comicVineId;

@Column(name = "StoryState", nullable = false, updatable = true)
@Enumerated(EnumType.STRING)
Expand Down
Expand Up @@ -92,12 +92,12 @@ public class StoryEntry {
@Setter
private Comic comic;

@Column(name = "ComicVineId", length = 16, nullable = true, updatable = true, unique = true)
@Column(name = "ComicVineId", nullable = true, updatable = true, unique = true)
@JsonProperty("comicVineId")
@JsonView(View.StoryList.class)
@Getter
@Setter
private String comicVineId;
private Integer comicVineId;

@Override
public boolean equals(final Object o) {
Expand Down
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet id="007_1046_make_comicvineid_a_number.xml"
author="mcpierce">

<modifyDataType tableName="Comics"
columnName="ComicVineId"
newDataType="int"/>
<createIndex tableName="Comics"
indexName="ComicComicVineIdIdx">
<column name="ComicVineId"/>
</createIndex>

<modifyDataType tableName="Stories"
columnName="ComicVineId"
newDataType="int"/>
<createIndex tableName="Stories"
indexName="StoryComicVineIdIdx">
<column name="ComicVineId"/>
</createIndex>

<modifyDataType tableName="StoryEntries"
columnName="ComicVineId"
newDataType="int"/>
<createIndex tableName="StoryEntries"
indexName="StoryEntryComicVineIdIdx">
<column name="ComicVineId"/>
</createIndex>

<!-- technical debt -->
<dropIndex tableName="Comics"
indexName="idx_added_date"/>

<dropIndex tableName="Comics"
indexName="idx_last_updated_date"/>
<createIndex tableName="Comics"
indexName="ComicLastModifiedOnIdx">
<column name="LastModifiedOn"/>
</createIndex>

<dropIndex tableName="Comics"
indexName="idx_comics_deleted_date"/>

</changeSet>
</databaseChangeLog>
Expand Up @@ -12,5 +12,6 @@
<include file="/db/migrations/0.11.0/004_44_added_story_details.xml"/>
<include file="/db/migrations/0.11.0/005_866_expand_comic_notes_column.xml"/>
<include file="/db/migrations/0.11.0/006_801_rename_scraping_rules_table.xml"/>
<include file="/db/migrations/0.11.0/007_1046_make_comicvineid_a_number.xml"/>

</databaseChangeLog>
Expand Up @@ -56,7 +56,7 @@
})
public class ComicRepositoryTest {
private static final String TEST_COMIC_SORT_NAME = "My First Comic";
private static final String TEST_COMIC_VINE_ID = "ABCDEFG";
private static final Integer TEST_COMIC_VINE_ID = 1234;
private static final long TEST_COMIC_ID = 1000L;
private static final long TEST_COMIC_ID_WITH_BLOCKED_PAGES = 1001L;
private static final Long TEST_COMIC_ID_WITH_DELETED_PAGES = 1002L;
Expand Down Expand Up @@ -139,13 +139,12 @@ public void testComicVineIdIsNullable() {

@Test
public void testComicVineIdIsUpdatable() {
String id = comic.getComicVineId().substring(1);
comic.setComicVineId(id);
comic.setComicVineId(comic.getComicVineId() + 1);
repository.save(comic);

Comic result = repository.findById(comic.getId()).get();

assertEquals(id, result.getComicVineId());
assertEquals(comic.getComicVineId(), result.getComicVineId());
}

@Test
Expand Down
22 changes: 11 additions & 11 deletions comixed-repositories/src/test/resources/test-database.xml
Expand Up @@ -16,7 +16,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1234"
CreatedOn="2017-06-16 15:21:00"
LastModifiedOn="2020-01-09 06:25:00"
CoverDate="2017-01-31"
Expand All @@ -36,7 +36,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1235"
CreatedOn="2017-06-15 15:20:00"
LastModifiedOn="2020-01-09 06:27:00"
CoverDate="2017-02-28"
Expand All @@ -54,7 +54,7 @@
ArchiveType="CBZ"
Publisher="DC"
Series="Action Comics"
ComicVineId="ABCDEFG"
ComicVineId="1236"
CreatedOn="2017-06-14 15:20:00"
LastModifiedOn="2020-01-09 06:26:00"
CoverDate="2017-01-31"
Expand All @@ -72,7 +72,7 @@
ArchiveType="CBZ"
Publisher="Warren"
Series="Creepy"
ComicVineId="ABCDEFG"
ComicVineId="1237"
CreatedOn="2017-06-13 15:20:00"
LastModifiedOn="2020-01-09 06:25:00"
CoverDate="1965-01-31"
Expand All @@ -90,7 +90,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1238"
CreatedOn="2017-06-15 15:20:00"
LastModifiedOn="2020-01-09 06:27:11"
CoverDate="2017-03-31"
Expand All @@ -108,7 +108,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1239"
CreatedOn="2017-06-15 15:20:10"
LastModifiedOn="2020-01-09 06:27:02"
CoverDate="2016-02-28"
Expand All @@ -126,7 +126,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1240"
CreatedOn="2017-06-15 15:20:20"
LastModifiedOn="2020-01-09 06:27:30"
CoverDate="2015-02-28"
Expand All @@ -144,7 +144,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Steve Rogers: Captain America"
ComicVineId="ABCDEFG"
ComicVineId="1241"
CreatedOn="2017-06-15 15:20:20"
LastModifiedOn="2020-01-09 06:27:30"
CoverDate="2015-02-28"
Expand All @@ -163,7 +163,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Nova"
ComicVineId="ABCDEFG"
ComicVineId="1242"
CreatedOn="2019-04-24 09:35:00"
LastModifiedOn="2019-04-24 09:35:00"
CoverDate="2017-02-31"
Expand All @@ -182,7 +182,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Nova"
ComicVineId="ABCDEFG"
ComicVineId="1243"
CreatedOn="2019-04-24 09:36:00"
LastModifiedOn="2019-04-24 09:36:00"
CoverDate="2017-02-31"
Expand All @@ -201,7 +201,7 @@
ArchiveType="CBZ"
Publisher="Marvel"
Series="Unwanted Comic"
COMICVINEId="ABCDEFG"
ComicVineId="1244"
CreatedOn="2019-04-24 09:36:00"
LastModifiedOn="2019-04-24 09:36:00"
CoverDate="2017-02-31"
Expand Down
Expand Up @@ -69,7 +69,7 @@ public ScrapingIssueDetails execute() throws ScrapingException {

log.debug("Populate the issue details");
final ScrapingIssueDetails result = new ScrapingIssueDetails();
result.setSourceId(String.valueOf(issueDetails.getId()));
result.setSourceId(issueDetails.getId());
result.setPublisher(publisherDetails.getName());
result.setSeries(volumeDetails.getName());
result.setVolume(volumeDetails.getStartYear());
Expand Down
Expand Up @@ -32,7 +32,7 @@
public class ComicVineIssue {
@JsonProperty("id")
@Getter
private String id;
private Integer id;

@JsonProperty("volume")
@Getter
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class ScrapingIssue {
@JsonProperty(value = "id")
@Getter
@Setter
private String id;
private Integer id;

@JsonProperty(value = "coverDate")
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
Expand Down
Expand Up @@ -35,7 +35,7 @@ public class ScrapingIssueDetails {
@JsonProperty("sourceId")
@Getter
@Setter
private String sourceId;
private Integer sourceId;

@JsonProperty("publisher")
@Getter
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class ComicVineGetIssueDetailsActionTest {
private static final String TEST_STORY_NAME = "Story Name";
private static final String TEST_CREDIT_NAME = "Credit Name";
private static final String TEST_CREDIT_ROLE = "Credit Role";
private static final String TEST_COMIC_VINE_ISSUE_ID = "71765";
private static final Integer TEST_COMIC_VINE_ISSUE_ID = 71765;

@InjectMocks private ComicVineGetIssueDetailsAction scrapeComicAction;
@Mock private ObjectFactory<ComicVineGetIssueWithDetailsAction> issueDetailsActionObjectFactory;
Expand Down Expand Up @@ -193,7 +193,7 @@ public void testExecute() throws ScrapingException {
this.verifyGetVolumeDetailsAction();
this.verifyGetPublisherDetailsAction();

assertEquals(String.valueOf(TEST_COMIC_VINE_ISSUE_ID), result.getSourceId());
assertEquals(TEST_COMIC_VINE_ISSUE_ID, result.getSourceId());
assertEquals(TEST_PUBLISHER_NAME, result.getPublisher());
assertEquals(TEST_VOLUME_NAME, result.getSeries());
assertEquals(TEST_START_YEAR, result.getVolume());
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class ComicServiceTest {
private static final String TEST_SERIES = "Series Name";
private static final String TEST_VOLUME = "Volume Name";
private static final String TEST_ISSUE_NUMBER = "237";
private static final String TEST_COMIC_VINE_ID = "2345";
private static final Integer TEST_COMIC_VINE_ID = 2345;
private static final int TEST_MAXIMUM_COMICS = 100;
private static final String TEST_PREVIOUS_ISSUE_NUMBER = "5";
private static final String TEST_CURRENT_ISSUE_NUMBER = "7";
Expand Down
Expand Up @@ -62,7 +62,7 @@ public class ScrapingServiceTest {
private static final String TEST_TITLE = "The Title";
private static final String TEST_DESCRIPTION = "This is the comic's description";
private static final String TEST_ISSUE_DETAILS_KEY = "IssueDetailsKey";
private static final String TEST_SOURCE_ID = "71765";
private static final Integer TEST_SOURCE_ID = 71765;

@InjectMocks private ScrapingService scrapingService;
@Mock private ScrapingCacheService scrapingCacheService;
Expand Down
10 changes: 5 additions & 5 deletions comixed-webui/src/app/comic-books/comic-books.fixtures.ts
Expand Up @@ -84,7 +84,7 @@ export const COMIC_1: Comic = {
notes: '',
missing: false,
archiveType: ArchiveType.CBZ,
comicVineId: '71765',
comicVineId: 71765,
addedDate: new Date().getTime(),
deletedDate: null,
coverDate: new Date().getTime(),
Expand Down Expand Up @@ -122,7 +122,7 @@ export const COMIC_2: Comic = {
notes: '',
missing: false,
archiveType: ArchiveType.CBZ,
comicVineId: '',
comicVineId: 7283,
addedDate: new Date().getTime(),
deletedDate: null,
coverDate: new Date().getTime(),
Expand Down Expand Up @@ -160,7 +160,7 @@ export const COMIC_3: Comic = {
notes: '',
missing: false,
archiveType: ArchiveType.CBZ,
comicVineId: '',
comicVineId: null,
addedDate: new Date().getTime(),
deletedDate: null,
coverDate: new Date().getTime(),
Expand Down Expand Up @@ -198,7 +198,7 @@ export const COMIC_4: Comic = {
notes: '',
missing: false,
archiveType: ArchiveType.CBZ,
comicVineId: '',
comicVineId: null,
addedDate: new Date().getTime(),
deletedDate: null,
coverDate: new Date().getTime(),
Expand Down Expand Up @@ -236,7 +236,7 @@ export const COMIC_5: Comic = {
notes: '',
missing: false,
archiveType: ArchiveType.CBZ,
comicVineId: '24601',
comicVineId: 24601,
addedDate: new Date().getTime(),
deletedDate: null,
coverDate: new Date().getTime(),
Expand Down
Expand Up @@ -331,7 +331,7 @@ describe('ComicEditComponent', () => {
expect(store.dispatch).toHaveBeenCalledWith(
scrapeComic({
apiKey: API_KEY,
issueId: parseInt(COMIC.comicVineId, 10),
issueId: COMIC.comicVineId,
comic: COMIC,
skipCache: SKIP_CACHE
})
Expand Down
Expand Up @@ -276,7 +276,7 @@ export class ComicEditComponent implements OnInit, OnDestroy {
this.store.dispatch(
scrapeComic({
apiKey: this.apiKey,
issueId: parseInt(this.comic.comicVineId, 10),
issueId: this.comic.comicVineId,
comic: this.comic,
skipCache: this.skipCache
})
Expand Down
2 changes: 1 addition & 1 deletion comixed-webui/src/app/comic-books/models/comic.ts
Expand Up @@ -45,7 +45,7 @@ export interface Comic {
sortableIssueNumber: string;
sortName: string;
imprint: string;
comicVineId: string;
comicVineId: number;
pageCount: number;
characters: string[];
teams: string[];
Expand Down
Expand Up @@ -240,13 +240,13 @@ describe('LibraryPageComponent', () => {
...COMIC_1,
lastRead: null,
deletedDate: null,
comicVineId: '54321'
comicVineId: 54321
};
const DELETED = {
...COMIC_3,
lastRead: new Date().getTime(),
deletedDate: new Date().getTime(),
comicVineId: '12345'
comicVineId: 12345
};
const UNSCRAPED = {
...COMIC_1,
Expand Down

0 comments on commit 5bf8feb

Please sign in to comment.