Skip to content

Commit 63537a7

Browse files
committed
feat: refactored stats and released recommendations feature
1 parent b3951eb commit 63537a7

5 files changed

Lines changed: 34 additions & 12 deletions

File tree

stats/analyzer/src/main/java/ru/practicum/model/EventSimilarity.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
@NoArgsConstructor
1313
@Builder
1414
@Entity
15-
@Table(name = "events_similarity")
15+
@Table(name = "similarities")
1616
@FieldDefaults(level = AccessLevel.PRIVATE)
1717
public class EventSimilarity {
1818
@Id
1919
@GeneratedValue(strategy = GenerationType.IDENTITY)
2020
Long id;
21-
21+
@Column(name = "event_id_a")
2222
Long eventA;
23+
@Column(name = "event_id_b")
2324
Long eventB;
25+
@Column(name = "score")
2426
Double score;
27+
@Column(name = "timestamp")
2528
Instant timestamp;
2629
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package ru.practicum.model;
22

33

4-
import jakarta.persistence.Entity;
5-
import jakarta.persistence.GeneratedValue;
6-
import jakarta.persistence.GenerationType;
7-
import jakarta.persistence.Id;
8-
import jakarta.persistence.Table;
4+
import jakarta.persistence.*;
95
import lombok.AllArgsConstructor;
106
import lombok.Builder;
117
import lombok.Getter;
@@ -20,16 +16,17 @@
2016
@NoArgsConstructor
2117
@Builder
2218
@Entity
23-
@Table(name = "user_actions")
19+
@Table(name = "actions")
2420
public class UserAction {
2521
@Id
2622
@GeneratedValue(strategy = GenerationType.IDENTITY)
2723
private Long id;
28-
24+
@Column(name = "user_id")
2925
private Long userId;
26+
@Column(name = "event_id")
3027
private Long eventId;
31-
28+
@Column(name = "score")
3229
private Double score;
33-
30+
@Column(name = "lastInteraction")
3431
private Instant lastInteraction;
3532
}

stats/analyzer/src/main/resources/application.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ spring:
1313
retry:
1414
useRandomPolicy: true
1515
max-interval: 6000
16+
flyway:
17+
flyway:
18+
database: postgresql
19+
ignore-future-migrations: true
20+
postgresql:
21+
transactional-lock: false
1622
eureka:
1723
client:
1824
serviceUrl:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE similarities (
2+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
3+
event_id_a BIGINT,
4+
event_id_b BIGINT,
5+
score DOUBLE PRECISION,
6+
timestamp TIMESTAMP with time zone,
7+
CONSTRAINT pk_similarities PRIMARY KEY (id)
8+
);
9+
10+
CREATE TABLE actions (
11+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
12+
user_id BIGINT,
13+
event_id BIGINT,
14+
score DOUBLE PRECISION,
15+
last_interaction TIMESTAMP with time zone,
16+
CONSTRAINT pk_actions PRIMARY KEY (id)
17+
);

stats/collector/src/main/java/ru/practicum/service/CollectorController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ru.practicum.service;
22

3-
import com.google.protobuf.Empty;
43
import io.grpc.Status;
54
import io.grpc.StatusRuntimeException;
65
import io.grpc.stub.StreamObserver;

0 commit comments

Comments
 (0)