-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add primary key to artworks table * Fix artwork caching bug
- Loading branch information
Showing
8 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
artgalleryclient/src/main/sqldelight/edu/gvsu/art/client/data/9_AddPrimaryKeyToArtworks.sqm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
BEGIN TRANSACTION; | ||
|
||
CREATE TABLE artworks_copy ( | ||
id TEXT NOT NULL PRIMARY KEY, | ||
is_public INTEGER, | ||
media_representations TEXT, | ||
name TEXT, | ||
artist_id TEXT, | ||
artist_name TEXT, | ||
historical_context TEXT, | ||
work_description TEXT, | ||
work_date TEXT, | ||
work_medium TEXT, | ||
location TEXT, | ||
identifier TEXT, | ||
credit_line TEXT, | ||
location_latitude REAL, | ||
location_longitude REAL, | ||
related_objects TEXT, | ||
media_small_url TEXT, | ||
media_medium_url TEXT, | ||
media_large_url TEXT, | ||
thumbnail_url TEXT, | ||
created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
ar_digital_asset_url TEXT | ||
); | ||
|
||
INSERT OR IGNORE INTO artworks_copy ( | ||
id, | ||
is_public, | ||
media_representations, | ||
name, | ||
artist_id, | ||
artist_name, | ||
historical_context, | ||
work_description, | ||
work_date, | ||
work_medium, | ||
location, | ||
identifier, | ||
credit_line, | ||
location_latitude, | ||
location_longitude, | ||
related_objects, | ||
media_small_url, | ||
media_medium_url, | ||
media_large_url, | ||
thumbnail_url, | ||
created_at, | ||
ar_digital_asset_url | ||
) | ||
SELECT | ||
id, | ||
is_public, | ||
media_representations, | ||
name, | ||
artist_id, | ||
artist_name, | ||
historical_context, | ||
work_description, | ||
work_date, | ||
work_medium, | ||
location, | ||
identifier, | ||
credit_line, | ||
location_latitude, | ||
location_longitude, | ||
related_objects, | ||
media_small_url, | ||
media_medium_url, | ||
media_large_url, | ||
thumbnail_url, | ||
created_at, | ||
ar_digital_asset_url | ||
FROM Artworks; | ||
|
||
DROP TABLE Artworks; | ||
|
||
ALTER TABLE artworks_copy RENAME TO Artworks; | ||
|
||
COMMIT; |
27 changes: 27 additions & 0 deletions
27
artgalleryclient/src/test/kotlin/edu/gvsu/art/client/repository/CachingTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package edu.gvsu.art.client.repository | ||
|
||
import junit.framework.TestCase.assertTrue | ||
import org.junit.Test | ||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
import kotlin.test.assertFalse | ||
|
||
class CachingTest { | ||
@Test | ||
fun isFreshCache_nullValue() { | ||
assertFalse(isFreshCache(cacheDateTime = null)) | ||
} | ||
|
||
@Test | ||
fun isFreshCache_oldDate() { | ||
assertFalse(isFreshCache(cacheDateTime = "2024-06-11 21:56:32")) | ||
} | ||
|
||
@Test | ||
fun isFreshCache_validDate() { | ||
val now = LocalDateTime.now().minusHours(1) | ||
|
||
assertTrue(isFreshCache(cacheDateTime = now.format(CACHE_TIME_FORMAT))) | ||
} | ||
} |