diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-11-03 07:09:42 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-11-03 07:09:42 +0100 |
commit | 5000f9a3b87bf7689cba3e03dca4ec8260d56fae (patch) | |
tree | 0194ab6e27eb25c19954e257500243b77ce58769 /src/main | |
parent | db9a1988bc688407c7957c5e55782f33a76d3de3 (diff) |
KB68 Only put public posts into the newsletter.
Change-Id: Iee7f4dfd14820c19179c43be71759f209caa9989
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java | 10 | ||||
-rw-r--r-- | src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java index 59ab37c..7a52d32 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java @@ -50,7 +50,15 @@ public class NewsletterSender { void run() throws InterruptedException, TimeoutException, ExecutionException { var session = em.unwrap(Session.class); - List<Post<?>> posts = Post.list("newsletter IS NULL", Sort.ascending("date")); + List<Post<?>> posts = + Post.list( + "" + + "SELECT p FROM Post p" + + " JOIN p.targets r" + + " JOIN r.tags tag" + + " WHERE newsletter IS NULL" + + " AND tag = 'world'", + Sort.ascending("date")); Post.fetchTexts(posts); if (posts.isEmpty()) { diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java index 43787dc..a9dda9c 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java @@ -16,8 +16,7 @@ public class NewsletterSubscriptionExpirer { void run() { var subscriptionsDeleted = NewsletterSubscription.delete( - "registrationKey IS NOT NULL AND startDate < ?1", - OffsetDateTime.now().minusWeeks(1)); + "registrationKey IS NOT NULL AND startDate < ?1", OffsetDateTime.now().minusWeeks(1)); if (subscriptionsDeleted > 0) { log.infof("%d expired newsletter subscriptions deleted.", subscriptionsDeleted); } |