1
0

Compare commits

...

3 Commits

5 changed files with 19 additions and 8 deletions

View File

@@ -27,7 +27,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@ConfigurationProperties(prefix = "messenger.database") @ConfigurationProperties(prefix = "messenger.database")
data class DatabaseProperties @ConstructorBinding constructor( data class DatabaseProperties @ConstructorBinding constructor(
val h2Path: String,
val jsonPath: String, val jsonPath: String,
) )
@@ -90,7 +89,6 @@ class Configuration {
).also { management -> ).also { management ->
logger.info("Loaded driver path: {}", driverProperties.driverPath) logger.info("Loaded driver path: {}", driverProperties.driverPath)
logger.info("Loaded binary path: {}", driverProperties.binaryPath) logger.info("Loaded binary path: {}", driverProperties.binaryPath)
logger.info("Loaded database path: {}", databaseProperties.h2Path)
logger.info("Loaded database path: {}", databaseProperties.jsonPath) logger.info("Loaded database path: {}", databaseProperties.jsonPath)
management management
.fetchConfiguration() .fetchConfiguration()

View File

@@ -1,11 +1,11 @@
package com.lanyuanxiaoyao.digtal.market package com.lanyuanxiaoyao.digtal.market
import com.blinkfox.fenix.jpa.FenixJpaRepository
import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor
import jakarta.persistence.Entity import jakarta.persistence.Entity
import jakarta.persistence.Id import jakarta.persistence.Id
import jakarta.persistence.Lob import jakarta.persistence.Lob
import java.util.Date import java.util.Date
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param import org.springframework.data.repository.query.Param
@@ -27,10 +27,15 @@ class Article(
var tags: String?, var tags: String?,
var createTime: Date?, var createTime: Date?,
var pushed: Boolean?, var pushed: Boolean?,
) var error: Int?,
) {
override fun toString(): String {
return "Article(id='$id', code='$code', url='$url', title=$title, author=$author, category=$category, text=$text, html=$html, subtitle=$subtitle, description=$description, tags=$tags, createTime=$createTime, pushed=$pushed, error=$error)"
}
}
@Repository @Repository
interface ArticleRepository : JpaRepository<Article, String>, FenixJpaSpecificationExecutor<Article> { interface ArticleRepository : FenixJpaRepository<Article, String>, FenixJpaSpecificationExecutor<Article> {
fun findAllByDescriptionIsNullAndTextIsNotNull(): List<Article> fun findAllByDescriptionIsNullAndTextIsNotNull(): List<Article>
fun findAllByHtmlIsNotNull(): List<Article> fun findAllByHtmlIsNotNull(): List<Article>
@@ -47,11 +52,14 @@ interface ArticleRepository : JpaRepository<Article, String>, FenixJpaSpecificat
@Query("update Article article set article.pushed = :pushed where article.id = :id") @Query("update Article article set article.pushed = :pushed where article.id = :id")
fun updatePushedById(@Param("id") id: String, @Param("pushed") pushed: Boolean) fun updatePushedById(@Param("id") id: String, @Param("pushed") pushed: Boolean)
@Query("select article.id from Article article where article.description is not null and article.text is not null and article.text <> ''") @Query("select article.id from Article article where (article.error is not null and article.error > 3) or (article.description is not null and article.text is not null and article.text <> '')")
fun findAllId(): List<String> fun findAllId(): List<String>
@Query("select new com.lanyuanxiaoyao.digtal.market.CountGroupByString(article.code, count(article.code)) from Article article group by article.code") @Query("select new com.lanyuanxiaoyao.digtal.market.CountGroupByString(article.code, count(article.code)) from Article article group by article.code")
fun countGroupByCode(): List<CountGroupByString> fun countGroupByCode(): List<CountGroupByString>
@Query("select article.error from Article article where article.id = :id")
fun findErrorById(@Param("id") id: String): Int?
} }
data class CountGroupByString( data class CountGroupByString(

View File

@@ -148,6 +148,7 @@ fun parseArticle(management: Management, code: String, url: String, hash: String
tags = null, tags = null,
createTime = createTime, createTime = createTime,
pushed = false, pushed = false,
error = null,
) )
} ?: return null } ?: return null
} }

View File

@@ -87,6 +87,11 @@ class NewsRunner : Runner {
article.subtitle = triple?.subtitle article.subtitle = triple?.subtitle
article.description = triple?.description article.description = triple?.description
article.tags = triple?.tags article.tags = triple?.tags
if (triple == null) {
val error = articleRepository.findErrorById(link.hash)
article.error = error?.plus(1) ?: 1
}
} }
article.category = keyword article.category = keyword

View File

@@ -14,7 +14,7 @@ spring:
ssl: ssl:
enable: true enable: true
datasource: datasource:
url: jdbc:mysql://frp-air.top:43458/digital_market url: jdbc:mysql://mysql.lanyuanxiaoyao.com:43780/digital_market
username: digital_market username: digital_market
password: diXe7hS7yETHJGGz password: diXe7hS7yETHJGGz
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
@@ -42,7 +42,6 @@ messenger:
driver-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/chromedriver driver-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/chromedriver
binary-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/Chromium.app/Contents/MacOS/Chromium binary-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/Chromium.app/Contents/MacOS/Chromium
database: database:
h2-path: ./database/database.db
json-path: ./database/database.json json-path: ./database/database.json
fenix: fenix:
print-banner: false print-banner: false