diff options
author | Vitaly Takmazov | 2018-01-12 10:36:36 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-01-12 10:37:11 +0300 |
commit | 59d08c3fe59077238e7f7774be359a7966ed522c (patch) | |
tree | 8267b366c8b36f557c1d4172df85d9094cf18d3d /juick-api/src/main/java/com/juick/api/TopManager.java | |
parent | 4b9186442839ab591ba04b6e2474edbcc3a2f6f8 (diff) |
api: merge top component
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/TopManager.java')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TopManager.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TopManager.java b/juick-api/src/main/java/com/juick/api/TopManager.java new file mode 100644 index 00000000..c762aa83 --- /dev/null +++ b/juick-api/src/main/java/com/juick/api/TopManager.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2008-2017, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.api; + +import com.juick.service.MessagesService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.inject.Inject; + +@Component +public class TopManager { + private static Logger logger = LoggerFactory.getLogger(TopManager.class); + @Inject + private MessagesService messagesService; + + @Scheduled(fixedRate = 120000) + public void updateTop() { + messagesService.getPopularCandidates().forEach(m -> { + logger.info("added {} to popular", m); + messagesService.setMessagePopular(m, 1); + }); + } +} |