File tree Expand file tree Collapse file tree 3 files changed +27
-15
lines changed
src/main/kotlin/org/gitanimals Expand file tree Collapse file tree 3 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,5 @@ class JacksonConfig {
25
25
.configure(DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false )
26
26
.configure(DeserializationFeature .FAIL_ON_MISSING_CREATOR_PROPERTIES , false )
27
27
.configure(DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES , false )
28
-
29
28
}
30
29
}
Original file line number Diff line number Diff line change 1
1
package org.gitanimals.star.infra
2
2
3
+ import com.fasterxml.jackson.annotation.JsonCreator
3
4
import org.springframework.beans.factory.annotation.Value
4
5
import org.springframework.context.annotation.Profile
5
6
import org.springframework.core.io.ClassPathResource
@@ -61,33 +62,33 @@ class GithubStargazerApi(
61
62
}
62
63
}
63
64
64
- data class GithubStargazerGraphqlResponse (
65
+ data class GithubStargazerGraphqlResponse @JsonCreator constructor (
65
66
val data : Data ,
66
67
) {
67
- data class Data (
68
+ data class Data @JsonCreator constructor (
68
69
val repository : Repository ,
69
70
) {
70
- data class Repository (
71
+ data class Repository @JsonCreator constructor (
71
72
val stargazers : StargazersResponse ,
72
73
)
73
74
}
74
75
}
75
76
76
- data class StargazersResponse (
77
+ data class StargazersResponse @JsonCreator constructor (
77
78
val edges : List <StarPushedPeople >,
78
79
val pageInfo : PageInfo ,
79
80
) {
80
81
81
- data class StarPushedPeople (
82
+ data class StarPushedPeople @JsonCreator constructor (
82
83
val starredAt : String ,
83
84
val node : Node ,
84
85
) {
85
- data class Node (
86
+ data class Node @JsonCreator constructor (
86
87
val login : String ,
87
88
)
88
89
}
89
90
90
- data class PageInfo (
91
+ data class PageInfo @JsonCreator constructor (
91
92
val endCursor : String ,
92
93
val hasNextPage : Boolean ,
93
94
)
Original file line number Diff line number Diff line change 1
1
package org.gitanimals.star.infra
2
2
3
3
import org.gitanimals.star.domain.StargazerService
4
+ import org.slf4j.LoggerFactory
4
5
import org.springframework.boot.context.event.ApplicationStartedEvent
5
6
import org.springframework.context.annotation.Profile
6
7
import org.springframework.context.event.EventListener
@@ -14,21 +15,32 @@ class StargazerBatchJob(
14
15
private val stargazerService : StargazerService ,
15
16
) {
16
17
18
+ private val logger = LoggerFactory .getLogger(this ::class .simpleName)
19
+
17
20
@EventListener(ApplicationStartedEvent ::class )
18
21
fun initStargazer () {
19
22
updateStargazer()
20
23
}
21
24
22
25
@Scheduled(cron = EVERY_DAY )
23
26
fun updateStargazer () {
24
- val stargazers = githubStargazerApi.getStargazers()
25
- stargazerService.updateAll(
26
- stargazers.flatMap { stargazer ->
27
- stargazer.edges.map { edge ->
28
- edge.node.login
27
+ runCatching {
28
+ val stargazers = githubStargazerApi.getStargazers()
29
+ stargazerService.updateAll(
30
+ stargazers.flatMap { stargazer ->
31
+ stargazer.edges.map { edge ->
32
+ edge.node.login
33
+ }
29
34
}
30
- }
31
- )
35
+ )
36
+ }.onSuccess {
37
+ logger.info(" [StargazerBatchJob] Success to aggregation stargazer counts." )
38
+ }.onFailure {
39
+ logger.error(
40
+ " [StargazerBatchJob] Fail to aggregation stargazer counts. cause: ${it.message} " ,
41
+ it
42
+ )
43
+ }
32
44
}
33
45
34
46
You can’t perform that action at this time.
0 commit comments