From f698ebcfbe0fb097080a64c86c2303c86b37b83b Mon Sep 17 00:00:00 2001 From: daniel-michel <65034538+daniel-michel@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:57:03 +0100 Subject: [PATCH] fix: update query in readme refactor: only show movies with at least one title in upcoming movies --- README.md | 3 ++- lib/main.dart | 11 ++++++++--- lib/model/movie.dart | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9eed07d..a435c46 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ SELECT WHERE { ?movie wdt:P31 wd:Q11424; # Q11424 is the item for "film" wdt:P577 ?releaseDate. # P577 is the "publication date" property - FILTER (xsd:date(?releaseDate) >= xsd:date("$date"^^xsd:dateTime)) + ?movie p:P577/psv:P577 [wikibase:timePrecision ?precision]. + FILTER (xsd:date(?releaseDate) >= xsd:date("$date"^^xsd:dateTime) && ?precision >= 10) } GROUP BY ?movie ORDER BY ?minReleaseDate diff --git a/lib/main.dart b/lib/main.dart index 5df387c..0169514 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,16 +50,21 @@ class HomePage extends StatelessWidget { Scaffold( body: MovieManagerList( manager, - // Only show movies that have a release date with at least month precision + // Only show movies that are bookmarked or have a release date with at least month precision and at least one title filter: (movie) => - movie.releaseDate.precision >= DatePrecision.month, + movie.bookmarked || + (movie.releaseDate.precision >= DatePrecision.month && + (movie.titles?.length ?? 0) >= 1), ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.refresh), onPressed: () => manager.loadUpcomingMovies(), ), ), - MovieManagerList(manager, filter: (movie) => movie.bookmarked) + MovieManagerList( + manager, + filter: (movie) => movie.bookmarked, + ) ], ), ), diff --git a/lib/model/movie.dart b/lib/model/movie.dart index d42e640..198b220 100644 --- a/lib/model/movie.dart +++ b/lib/model/movie.dart @@ -192,9 +192,9 @@ class DateWithPrecisionAndCountry { return switch (precision) { DatePrecision.decade => "${DateFormat("yyyy").format(date).substring(0, 3)}0s", - DatePrecision.year => date.year.toString(), - DatePrecision.month => DateFormat("MMMM yyyy").format(date), - DatePrecision.day => DateFormat("MMMM d, yyyy").format(date), + DatePrecision.year => DateFormat.y().format(date), + DatePrecision.month => DateFormat.yMMMM().format(date), + DatePrecision.day => DateFormat.yMMMMd().format(date), DatePrecision.hour => DateFormat("MMMM d, yyyy, HH").format(date), DatePrecision.minute => DateFormat("MMMM d, yyyy, HH:mm").format(date) };