Skip to content

Commit

Permalink
TopicListService -> scala
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcom committed Aug 11, 2023
1 parent f513bd0 commit b6c8f18
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 350 deletions.
9 changes: 4 additions & 5 deletions src/main/java/ru/org/linux/tag/TagPageController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import scala.concurrent.*
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.*
import scala.jdk.CollectionConverters.*
import scala.jdk.OptionConverters.RichOption

object TagPageController {
private val TotalNewsCount = 21
Expand Down Expand Up @@ -154,8 +153,8 @@ class TagPageController(tagService: TagService, prepareService: TopicPrepareServ

private def getNewsSection(tag: String, currentUser: Option[User]) = {
val newsSection = sectionService.getSection(Section.SECTION_NEWS)
val newsTopics = topicListService.getTopicsFeed(newsSection, null, tag, 0, None.toJava, None.toJava,
TagPageController.TotalNewsCount, currentUser.orNull, false, false).asScala
val newsTopics = topicListService.getTopicsFeed(Some(newsSection), None, Some(tag), 0, None,
TagPageController.TotalNewsCount, currentUser, noTalks = false, tech = false)

val (fullNewsTopics, briefNewsTopics) = if (newsTopics.headOption.map(_.commitDate.toInstant).exists(isRecent)) {
newsTopics.splitAt(1)
Expand All @@ -164,7 +163,7 @@ class TagPageController(tagService: TagService, prepareService: TopicPrepareServ
}

val tmpl = Template.getTemplate
val fullNews = prepareService.prepareTopicsForUser(fullNewsTopics.asJava, currentUser.orNull, tmpl.getProf, loadUserpics = false)
val fullNews = prepareService.prepareTopicsForUser(fullNewsTopics, currentUser.orNull, tmpl.getProf, loadUserpics = false)

val briefNewsByDate = TopicListTools.datePartition(briefNewsTopics)

Expand Down Expand Up @@ -213,7 +212,7 @@ class TagPageController(tagService: TagService, prepareService: TopicPrepareServ
topicListDto.setTag(tagId)
topicListDto.setLimit(TagPageController.ForumTopicCount)

val forumTopics = topicListService.getTopics(topicListDto, currentUser.orNull).asScala
val forumTopics = topicListService.getTopics(topicListDto, currentUser)
val topicByDate = TopicListTools.datePartition(forumTopics)

val more = if (forumTopics.size == TagPageController.ForumTopicCount) {
Expand Down
300 changes: 0 additions & 300 deletions src/main/java/ru/org/linux/topic/TopicListService.java

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/scala/ru/org/linux/spring/MainPageController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1998-2022 Linux.org.ru
* Copyright 1998-2023 Linux.org.ru
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -44,7 +44,7 @@ class MainPageController(
val profile = tmpl.getProf

val allTopics = topicListService.getMainPageFeed(tmpl.getProf.isShowGalleryOnMain, 25,
profile.isMiniNewsBoxletOnMainPage).asScala
profile.isMiniNewsBoxletOnMainPage)

val (messages, titles) = allTopics.foldLeft((Vector.empty[Topic], Vector.empty[Topic])) { case ((big, small), topic) =>
if (big.count(!_.minor)<5) {
Expand All @@ -58,7 +58,7 @@ class MainPageController(

mv.getModel.put("news",
prepareService.prepareTopicsForUser(
messages.asJava,
messages,
AuthUtil.getCurrentUser,
profile,
loadUserpics = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import ru.org.linux.tag.{TagName, TagNotFoundException, TagService}
import ru.org.linux.user.UserTagService

import scala.jdk.CollectionConverters.SeqHasAsJava
import scala.jdk.OptionConverters.RichOption

@Controller
object TagTopicListController {
Expand Down Expand Up @@ -116,8 +115,8 @@ class TagTopicListController (userTagService: UserTagService, sectionService: Se
}
}

val topics = topicListService.getTopicsFeed(section.orNull, null, tag, offset, None.toJava, None.toJava,
20, currentUserOpt.map(_.user).orNull, false, false)
val topics = topicListService.getTopicsFeed(section, None, Some(tag), offset, None,
20, currentUserOpt.map(_.user), noTalks = false, tech = false)

val tmpl = Template.getTemplate

Expand Down
Loading

0 comments on commit b6c8f18

Please sign in to comment.