Skip to content

Commit

Permalink
Merge pull request #234 from JasonHHouse/improvement/collection_movie…
Browse files Browse the repository at this point in the history
…_years

Improvement/collection movie years
  • Loading branch information
JasonHHouse authored Jun 3, 2021
2 parents 9e39165 + 51fb212 commit 0da5677
Show file tree
Hide file tree
Showing 28 changed files with 83 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
35 changes: 21 additions & 14 deletions Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ public final class MovieFromCollection {
private final Integer tmdbId;
@NotNull
private final Boolean owned;
@NotNull
private final Integer year;

@JsonCreator
public MovieFromCollection(@JsonProperty(value = "title") @Nullable String title,
@JsonProperty(value = "tmdbId") @Nullable Integer tmdbId,
@JsonProperty(value = "owned") @Nullable Boolean owned) {
@JsonProperty(value = "owned") @Nullable Boolean owned,
@JsonProperty(value = "year") @Nullable Integer year) {
this.title = StringUtils.isEmpty(title) ? "" : title;
this.tmdbId = tmdbId == null ? -1 : tmdbId;
this.owned = owned != null && owned;
this.year = year == null ? -1 : year;
}

@NotNull
Expand All @@ -39,27 +43,30 @@ public Boolean getOwned() {
return owned;
}

public Integer getYear() {
return year;
}

@Override
public String toString() {
return "MovieFromCollection{" +
"title='" + title + '\'' +
", tmdbId=" + tmdbId +
", owned=" + owned +
", year=" + year +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MovieFromCollection that = (MovieFromCollection) o;
return title.equals(that.title) &&
tmdbId.equals(that.tmdbId) &&
owned.equals(that.owned);
return title.equals(that.title) && tmdbId.equals(that.tmdbId) && owned.equals(that.owned) && year.equals(that.year);
}

@Override
public int hashCode() {
return Objects.hash(title, tmdbId, owned);
}

@Override
public String toString() {
return "MovieFromCollection{" +
"title='" + title + '\'' +
", id='" + tmdbId + '\'' +
", owned=" + owned +
'}';
return Objects.hash(title, tmdbId, owned, year);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,40 @@ class BasicMovieFromCollectionTest {

@Test
void MovieFromCollectionTest_Invalid_Owned (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, true);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, true, 5);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of owned field");
}

@Test
void MovieFromCollectionTest_Invalid_Id (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 9874, false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 9874, false, 5);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of ID field");
}

@Test
void MovieFromCollectionTest_Invalid_Name (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false, 5);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of name field");
}

@Test
void MovieFromCollectionTest_Invalid_Year (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false, 4);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of year field");
}

@Test
void MovieFromCollectionTest_Valid (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, false, 5);

assertEquals(movieFromCollection1, movieFromCollection2, "Movies should be equal");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.properties.DiscordProperties;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -34,16 +31,17 @@ void setUp() {

@Test
void testReadingFromJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", MovieFromCollection.class);
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true,\"year\":5}}", MovieFromCollection.class);
assertEquals("TITLE", movieFromCollection.getTitle(), "Title should be 'TITLE'");
assertEquals(123, movieFromCollection.getTmdbId(), "tmdbId should be '123'");
assertTrue(movieFromCollection.getOwned(), "Title should be 'TITLE'");
assertEquals(5, movieFromCollection.getYear(), "year should be '5'");
}

@Test
void testWritingToJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true);
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true, 5);
String json = objectMapper.writeValueAsString(movieFromCollection);
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", json, "JSON output should be equal");
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true,\"year\":5}", json, "JSON output should be equal");
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.raspbian
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.riscv64
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion GapsAsJar/gaps.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ RMDIR /r $INSTDIR
SectionEnd

# name the installer
OutFile "gaps-0.9.4-installer.exe"
OutFile "gaps-0.9.5-installer.exe"
2 changes: 1 addition & 1 deletion GapsWeb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
Expand Down Expand Up @@ -500,7 +499,7 @@ private void handleCollection(PlexProperties plexProperties, String machineIdent
LOGGER.info(collectionBasicMovie.toString());

Boolean owned = ownedBasicMovies.contains(collectionBasicMovie);
moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned));
moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned, year));
});
}

Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.9.4
version: 0.9.5
storageFolder: /usr/data
properties:
rssFeed: rssFeed.json
Expand Down
6 changes: 6 additions & 0 deletions GapsWeb/src/main/resources/static/js/page/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ jQuery(($) => {
isEqual(a, b) {
return a === b;
},
getYear(year) {
if (year && (year !== -1 || year !== 0)) {
return ` (${year})`;
}
return '';
},
});

libraryTitle = $('#libraryTitle');
Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">About</h3>
<h4 class="top-margin text-primary">v0.9.4</h4>
<h4 class="top-margin text-primary">v0.9.5</h4>

<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known
Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="container bottom-margin">
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">v0.9.4</h3>
<h3 class="top-margin">v0.9.5</h3>

<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known
Expand Down
6 changes: 3 additions & 3 deletions GapsWeb/src/main/resources/templates/recommended.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h5 class="card-title">Owned</h5>
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
class="list-group-item list-group-item-action"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{/if}}
{{/each}}
</div>
Expand All @@ -170,12 +170,12 @@ <h5 class="card-title">Missing</h5>
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
class="list-group-item list-group-item-action active"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{else}}
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
class="list-group-item list-group-item-action"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{/if}}
{{/if}}
{{/each}}
Expand Down
5 changes: 5 additions & 0 deletions GapsWeb/src/main/resources/templates/updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">Updates</h3>
<h4 class="top-margin text-primary">v0.9.5</h4>
<ul class="text-muted">
<li>Adding years collection movies</li>
</ul>

<h4 class="top-margin text-primary">v0.9.4</h4>
<ul class="text-muted">
<li>Adding genres to owned and recommended movies</li>
Expand Down
2 changes: 1 addition & 1 deletion Plex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion RadarrV3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion application-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.9.4
version: 0.9.5
storageFolder: /{CUSTOM_FOLDER} #Change to folder that gaps has permission to read, write, and delete in.
properties:
rssFeed: rssFeed.json
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##

set -e
VERSION=0.9.4
VERSION=0.9.5
JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"
ZIP_VERSION="GapsAsJar-$VERSION.zip"
npm ci
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call npm run uglifyjs-pages
call mvn clean install
del GapsOnWindows\*.jar
del GapsOnWindows\README.md
copy GapsWeb\target\GapsWeb-0.9.4.jar GapsOnWindows\gaps.jar
copy GapsWeb\target\GapsWeb-0.9.5.jar GapsOnWindows\gaps.jar
copy README.md GapsOnWindows\
cd GapsOnWindows
makensis gaps.nsi
2 changes: 1 addition & 1 deletion cypress/integration/about/about.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Verify About Page', () => {
.should('have.text', 'About');

cy.get('.container > :nth-child(3)')
.should('have.text', 'v0.9.4');
.should('have.text', 'v0.9.5');

cy.get('.container > :nth-child(6)')
.should('have.text', 'Software');
Expand Down
Loading

0 comments on commit 0da5677

Please sign in to comment.