Skip to content

Commit 070d58e

Browse files
authored
Merge pull request #20 from ydb-platform/fix-task
Remove save author implementations
2 parents 7754ad3 + 78728f0 commit 070d58e

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

dev-1/lesson-8.1/java/src/main/java/tech/ydb/app/Application.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public static void main(String[] args) {
2929
schemaYdbRepository.dropSchema();
3030
schemaYdbRepository.createSchema();
3131
issueYdbRepository.saveAll(List.of(
32-
new TitleAuthor("Ticket 1", "Author 1"),
33-
new TitleAuthor("Ticket 2", "Author 2"),
34-
new TitleAuthor("Ticket 3", "Author 3"))
32+
"Ticket 1",
33+
"Ticket 2",
34+
"Ticket 3"
35+
)
3536
);
3637

3738
var allTickets = issueYdbRepository.findAll();

dev-1/lesson-8.1/java/src/main/java/tech/ydb/app/IssueYdbRepository.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,19 @@ public List<Issue> findByIds(List<Long> ids) {
4949
/**
5050
* Пакетное добавление нескольких тикетов за один запрос
5151
*/
52-
public void saveAll(List<TitleAuthor> titleAuthors) {
52+
public void saveAll(List<String> issues) {
5353

5454
// Тут описывается структура данных, которая будет служить виртуальной таблицей.
5555
var structType = StructType.of(
5656
"id", PrimitiveType.Int64,
5757
"title", PrimitiveType.Text,
58-
"author", OptionalType.of(PrimitiveType.Text),
5958
"created_at", PrimitiveType.Timestamp
6059
);
6160

6261
var listIssues = Params.of("$args", ListType.of(structType).newValue(
63-
titleAuthors.stream().map(issue -> structType.newValue(
62+
issues.stream().map(issue -> structType.newValue(
6463
"id", PrimitiveValue.newInt64(ThreadLocalRandom.current().nextLong()),
65-
"title", PrimitiveValue.newText(issue.title()),
66-
"author", OptionalType.of(PrimitiveType.Text).newValue(PrimitiveValue.newText(issue.author())),
64+
"title", PrimitiveValue.newText(issue),
6765
"created_at", PrimitiveValue.newTimestamp(Instant.now())
6866
)).toList()
6967
));
@@ -72,7 +70,6 @@ public void saveAll(List<TitleAuthor> titleAuthors) {
7270
DECLARE $args AS List<Struct<
7371
id: Int64,
7472
title: Text,
75-
author: Text?, -- тут знак вопроса означает, что в Timestamp может быть передан NULL
7673
created_at: Timestamp,
7774
>>;
7875

dev-1/lesson-8.1/java/src/main/java/tech/ydb/app/TitleAuthor.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)