Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"Bash(git checkout:*)",
"Bash(mvn -B spring-boot:run)"
]
}
}
102 changes: 75 additions & 27 deletions .github/workflows/github-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,101 @@
# GitHub Actions CI/CD pipeline for a Java project using Maven
# File path should be: .github/workflows/github-ci-cd.yml
#
# Testy podzielone są na stage'e zgodnie z laboratoriami:
# - lab02 -> DatabaseSchemaTest (encje z LAB02)
# - lab03-entities -> Lab03EntitiesTest (encje z LAB03, STAGE 1)
#
# Stage'e testowe są niezależne (brak `needs:` między nimi), więc niepowodzenie
# jednego nie przerywa pozostałych — widzisz pełny obraz, które laboratorium
# już zielenie się, a które jeszcze nie. Job `package` buduje JAR tylko,
# gdy wszystkie stage'e są zielone.
name: Java CI with Maven

permissions:
contents: read
security-events: write

on:
push:
branches: [ "master" ]
branches: [ "**" ]
pull_request:
branches: [ "master" ]
branches: [ "**" ]

jobs:
build:
lab02:
name: LAB02 — schema (DatabaseSchemaTest)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Run LAB02 tests
run: mvn -B test -Dtest=DatabaseSchemaTest -DfailIfNoTests=false --file pom.xml

- name: Publish LAB02 test results
if: always()
uses: actions/upload-artifact@v5
with:
name: surefire-lab02
path: target/surefire-reports/
if-no-files-found: ignore
retention-days: 7

lab03-entities:
name: LAB03-1 — entities (Lab03EntitiesTest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up JDK 17
id: setup-jdk
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
publish-job:

- name: Run LAB03-1 tests
run: mvn -B test -Dtest=Lab03EntitiesTest -DfailIfNoTests=false --file pom.xml

- name: Publish LAB03-1 test results
if: always()
uses: actions/upload-artifact@v5
with:
name: surefire-lab03-entities
path: target/surefire-reports/
if-no-files-found: ignore
retention-days: 7

package:
name: Package JAR
runs-on: ubuntu-latest
needs: build
needs: [ lab02, lab03-entities ]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- run: mvn --batch-mode --update-snapshots verify
- name: Prepare staging
id: prepare-staging
run: |
mkdir -p staging
find target -maxdepth 1 -type f -name '*.jar' ! -name '*SNAPSHOT*' -exec cp {} staging/ \;
if [ -n "$(ls -A staging 2>/dev/null)" ]; then
echo "found=true" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: Upload package
if: steps.prepare-staging.outputs.found == 'true'
cache: maven

- name: Build JAR
run: mvn -B -DskipTests package --file pom.xml

- name: Upload JAR artifact
if: success()
uses: actions/upload-artifact@v5
with:
name: Package
path: staging
name: package
path: target/*.jar
if-no-files-found: ignore
retention-days: 7
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ build/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

### Java ###
target/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# FitnessTracker_LM-SS

Lukasz Malinowski 81518
</br>
Sebastian Skowron 81477
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>pl.wsb</groupId>
<artifactId>CapWSB-FitnessTracker</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0-81518-81477-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand Down Expand Up @@ -101,6 +101,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version> </path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
48 changes: 48 additions & 0 deletions src/main/java/pl/wsb/fitnesstracker/achievement/Achievement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package pl.wsb.fitnesstracker.achievement;

import jakarta.persistence.*;
import pl.wsb.fitnesstracker.user.api.User;
import java.time.LocalDateTime;

@Entity
@Table(name = "achievement")
public class Achievement {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String name;

@Column(name = "earned_at")
private LocalDateTime earnedAt;

@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;

protected Achievement() {
}

public Achievement(String name, LocalDateTime earnedAt, User user) {
this.name = name;
this.earnedAt = earnedAt;
this.user = user;
}

public Long getId() {
return id;
}

public String getName() {
return name;
}

public LocalDateTime getEarnedAt() {
return earnedAt;
}

public User getUser() {
return user;
}
}
53 changes: 52 additions & 1 deletion src/main/java/pl/wsb/fitnesstracker/event/Event.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
package pl.wsb.fitnesstracker.event;

// TODO: Define the Event entity with appropriate fields and annotations
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDateTime;

@Entity
@Table(name = "event")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString
public class Event {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Nullable
private Long id;

@Column(nullable = false)
private String name;

@Column
private String description;

@Column(name = "start_time", nullable = false)
private LocalDateTime startTime;

@Column(name = "end_time")
private LocalDateTime endTime;

@Column
private String country;

@Column
private String city;

public Event(
final String name,
final String description,
final LocalDateTime startTime,
final LocalDateTime endTime,
final String country,
final String city) {
this.name = name;
this.description = description;
this.startTime = startTime;
this.endTime = endTime;
this.country = country;
this.city = city;
}
}
21 changes: 21 additions & 0 deletions src/main/java/pl/wsb/fitnesstracker/event/EventRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pl.wsb.fitnesstracker.event;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

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

public interface EventRepository extends JpaRepository<Event, Long> {

@Query("SELECT e FROM Event e WHERE e.startTime > :now ORDER BY e.startTime")
List<Event> findUpcoming(@Param("now") LocalDateTime now);

@Query(
value = "SELECT e.name, COUNT(ue.id) FROM event e LEFT JOIN user_event ue ON e.id = ue.event_id GROUP BY e.id, e.name",
nativeQuery = true
)

List<Object[]> getEventsWithParticipantCount();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.wsb.fitnesstracker.healthmetrics;
package pl.wsb.fitnesstracker.healthmetrics.api;

import jakarta.annotation.Nullable;
import jakarta.persistence.*;
Expand Down Expand Up @@ -26,19 +26,24 @@ public class HealthMetrics {
@JoinColumn(name = "user_id", nullable = false)
private User user;

@Column(nullable = false)
@Column(name = "date", nullable = false)
private LocalDate date;

@Column(nullable = false)
private double weight;
@Column(name = "weight", nullable = false)
private Double weight;

@Column(nullable = false)
private double height;
@Column(name = "height", nullable = false)
private Double height;

@Column(name = "heart_rate", nullable = false)
private int heartRate;

public HealthMetrics(User user, LocalDate date, double weight, double height, int heartRate) {
private Integer heartRate;

public HealthMetrics(
final User user,
final LocalDate date,
final Double weight,
final Double height,
final Integer heartRate) {
this.user = user;
this.date = date;
this.weight = weight;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pl.wsb.fitnesstracker.healthmetrics.api;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.annotation.Nullable;

import java.time.LocalDate;

public record HealthMetricsDto(
@Nullable Long id,
Long userId,
@JsonFormat(pattern = "yyyy-MM-dd") LocalDate date,
Double weight,
Double height,
Integer heartRate) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pl.wsb.fitnesstracker.healthmetrics.api;

import pl.wsb.fitnesstracker.exception.api.NotFoundException;

@SuppressWarnings("squid:S110")
public class HealthMetricsNotFoundException extends NotFoundException {

private HealthMetricsNotFoundException(String message) {
super(message);
}

public HealthMetricsNotFoundException(Long id) {
this("HealthMetrics with ID=%s was not found".formatted(id));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pl.wsb.fitnesstracker.healthmetrics.api;

import java.util.List;
import java.util.Optional;

public interface HealthMetricsProvider {
Optional<HealthMetrics> getHealthMetrics(Long healthMetricsId);

List<HealthMetrics> getHealthMetricsByUserId(Long userId);

List<HealthMetrics> findAllHealthMetrics();

}
Loading