Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3af128e
Deleted social networks: vk, yandex in html code and also deleted cod…
ViktorKapustianyk Apr 19, 2024
9b223f9
Merge pull request #1 from ViktorKapustianyk/delete-social-networks-v…
ViktorKapustianyk Apr 19, 2024
f26761f
Exported sensitive information to a separate property file:
ViktorKapustianyk Apr 19, 2024
4375242
Merge pull request #2 from ViktorKapustianyk/export-sensitive-informa…
ViktorKapustianyk Apr 19, 2024
38f265b
Changed settings and now tests use the in-memory database (H2) during…
ViktorKapustianyk Apr 20, 2024
f50a8dc
Added some necessary settings that helps start the project and also t…
ViktorKapustianyk Apr 20, 2024
4d4b7c0
Merge pull request #3 from ViktorKapustianyk/during-tests-uses-memory…
ViktorKapustianyk Apr 20, 2024
db7255c
- define 2 bins
ViktorKapustianyk Apr 22, 2024
919b13d
Merge branch 'tests-uses-memory-database(H2)'
ViktorKapustianyk Apr 22, 2024
f6fd35c
Wrote tests for all public methods of the Profile Rest Controller.
ViktorKapustianyk Apr 23, 2024
66b6a5c
Merge pull request #5 from ViktorKapustianyk/write-tests-for-methods-…
ViktorKapustianyk Apr 23, 2024
d192828
Refactored the FileUtil/upload method and it uses a modern approach t…
ViktorKapustianyk Apr 23, 2024
3de5ff6
Merge pull request #6 from ViktorKapustianyk/make-refactoring-method-…
ViktorKapustianyk Apr 23, 2024
b37a1b3
Added new functionality: adding tags to the task (REST API + implemen…
ViktorKapustianyk Apr 23, 2024
c50c0a6
Added new functionality: adding tags to the task (REST API + implemen…
ViktorKapustianyk Apr 23, 2024
faa9822
Merge pull request #7 from ViktorKapustianyk/add-functionality-adding…
ViktorKapustianyk Apr 23, 2024
6d12c27
Added the amount of time: how much the task was in work and testing. …
ViktorKapustianyk Apr 23, 2024
1eb4c17
Merge pull request #8 from ViktorKapustianyk/add-time-count-task-inwo…
ViktorKapustianyk Apr 23, 2024
cb91870
Two bins and profiles were created. For the native profile, the PostG…
ViktorKapustianyk Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,23 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv -->
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>java-dotenv</artifactId>
<version>5.2.2</version>
</dependency>
</dependencies>

<build>
<finalName>root</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -175,6 +189,12 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<profiles>
Expand All @@ -195,5 +215,23 @@
</plugins>
</build>
</profile>
<profile>
<id>nativeTest</id>
<properties>
<spring.profiles.active>nativeTest</spring.profiles.active>
</properties>
<dependencies>

</dependencies>
</profile>
<profile>
<id>native</id>
<properties>
<spring.profiles.active>native</spring.profiles.active>
</properties>
<dependencies>

</dependencies>
</profile>
</profiles>
</project>
12 changes: 0 additions & 12 deletions resources/static/fontawesome/css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -8603,10 +8603,6 @@ readers do not read off random characters that represent icons */
content: "\f3e8";
}

.fa-vk:before {
content: "\f189";
}

.fa-untappd:before {
content: "\f405";
}
Expand Down Expand Up @@ -9955,10 +9951,6 @@ readers do not read off random characters that represent icons */
content: "\f3bc";
}

.fa-yandex:before {
content: "\f413";
}

.fa-readme:before {
content: "\f4d5";
}
Expand Down Expand Up @@ -10183,10 +10175,6 @@ readers do not read off random characters that represent icons */
content: "\f7c6";
}

.fa-yandex-international:before {
content: "\f414";
}

.fa-cc-amex:before {
content: "\f1f3";
}
Expand Down
2 changes: 1 addition & 1 deletion resources/static/fontawesome/css/all.min.css

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions resources/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ <h3 class="mb-3">Sign in</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
8 changes: 0 additions & 8 deletions resources/view/unauth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ <h3 class="mb-3">Registration</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
15 changes: 15 additions & 0 deletions sensitive-properties.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

SPRING_DATASOURCE_USERNAME=jira
SPRING_DATASOURCE_PASSWORD=JiraRush

SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GITHUB_CLIENT_ID=3d0d8738e65881fff266
SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GITHUB_CLIENT_SECRET=0f97031ce6178b7dfb67a6af587f37e222a16120

SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_ID=329113642700-f8if6pu68j2repq3ef6umd5jgiliup60.apps.googleusercontent.com
SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_SECRET=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

SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLAB_CLIENT_ID=b8520a3266089063c0d8261cce36971defa513f5ffd9f9b7a3d16728fc83a494
SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GITLAB_CLIENT_SECRET=e72c65320cf9d6495984a37b0f9cc03ec46be0bb6f071feaebbfe75168117004

SPRING_MAIL_USERNAME=jira4jr@gmail.com
SPRING_MAIL_PASSWORD=zdfzsrqvgimldzyj
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ public static void upload(MultipartFile multipartFile, String directoryPath, Str
throw new IllegalRequestDataException("Select a file to upload.");
}

File dir = new File(directoryPath);
if (dir.exists() || dir.mkdirs()) {
File file = new File(directoryPath + fileName);
try (OutputStream outStream = new FileOutputStream(file)) {
outStream.write(multipartFile.getBytes());
Path directory = Paths.get(directoryPath);
if (!Files.exists(directory)) {
try {
Files.createDirectories(directory);
} catch (IOException ex) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
throw new IllegalRequestDataException("Failed to create directory: " + directoryPath);
}
}

Path filePath = directory.resolve(fileName);
try {
Files.write(filePath, multipartFile.getBytes());
} catch (IOException ex) {
throw new IllegalRequestDataException("Failed to upload file: " + multipartFile.getOriginalFilename());
}
}

public static Resource download(String fileLink) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;

import static com.javarush.jira.bugtracking.task.TaskUtil.getLatestValue;
Expand Down Expand Up @@ -73,4 +75,46 @@ private void updateTaskIfRequired(long taskId, String activityStatus, String act
}
}
}

public Duration calculateTimeInProgress(Task task) {
List<Activity> activities = handler.getRepository().findAllByTaskIdOrderByUpdatedDesc(task.getId());
LocalDateTime inProgressTime = null;
LocalDateTime readyForReviewTime = null;

for (Activity activity : activities) {
if ("in_progress".equals(activity.getStatusCode())) {
inProgressTime = activity.getUpdated();
} else if ("ready_for_review".equals(activity.getStatusCode())) {
readyForReviewTime = activity.getUpdated();
break;
}
}

if (inProgressTime != null && readyForReviewTime != null) {
return Duration.between(inProgressTime, readyForReviewTime);
} else {
return Duration.ZERO;
}
}

public Duration calculateTimeInTesting(Task task) {
List<Activity> activities = handler.getRepository().findAllByTaskIdOrderByUpdatedDesc(task.getId());
LocalDateTime readyForReviewTime = null;
LocalDateTime doneTime = null;

for (Activity activity : activities) {
if ("ready_for_review".equals(activity.getStatusCode())) {
readyForReviewTime = activity.getUpdated();
} else if ("done".equals(activity.getStatusCode())) {
doneTime = activity.getUpdated();
break;
}
}

if (readyForReviewTime != null && doneTime != null) {
return Duration.between(readyForReviewTime, doneTime);
} else {
return Duration.ZERO;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,10 @@ public TaskTreeNode(TaskTo taskTo) {
this(taskTo, new LinkedList<>());
}
}
@PostMapping("/{id}/tags")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> addTagToTask(@PathVariable long id, @RequestBody String tagText) {
taskService.addTagToTask(id, tagText);
return ResponseEntity.status(HttpStatus.CREATED).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,11 @@ private void checkAssignmentActionPossible(long id, String userType, boolean ass
throw new DataConflictException(String.format(assign ? CANNOT_ASSIGN : CANNOT_UN_ASSIGN, userType, task.getStatusCode()));
}
}

@Transactional
public void addTagToTask(long taskId, String tagText) {
Task task = handler.getRepository().getExisted(taskId);
task.getTags().add(tagText);
handler.getRepository().save(task);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.javarush.jira.common.internal.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;

@Configuration
@Profile("nativeTest")
public class H2DataSourceConfig {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.javarush.jira.common.internal.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;

@Configuration
@Profile("native")
public class PostgreSqlDataSourceConfig {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.postgresql.Driver");
dataSource.setUrl("jdbc:postgresql://localhost:5432/jira");
dataSource.setUsername("jira");
dataSource.setPassword("JiraRush");
return dataSource;
}
}

This file was deleted.

This file was deleted.

Loading