Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI/CD using github actions & docker

on:
workflow_dispatch:
push:
branches:
- develop
Expand Down Expand Up @@ -54,6 +53,10 @@ jobs:
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: Get Github action IP
id: ip
uses: haythem/public-ip@v1.2

Comment on lines +56 to +59
- name: Deploy to prod
if: contains(github.ref, 'develop') || contains(github.ref, 'main')
uses: appleboy/ssh-action@master
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ jobs:
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: Get Github action IP
id: ip
uses: haythem/public-ip@v1.2

Comment on lines +59 to +62
- name: Deploy to prod
if: contains(github.ref, 'develop') || contains(github.ref, 'main')
uses: appleboy/ssh-action@master
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ out/
###claude###
.claude
.serena

# Local-only config
/src/main/resources/application-local.yml
/.env.local
/docker-compose.local.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@

public interface BLEDataRepository extends JpaRepository<BLEData, Long> {
Optional<BLEData> findTopByDeviceOrderByLastTimeDesc(BLEDevice device);
Optional<BLEData> findTopByDeviceOrderByLastTimeDescIdDesc(BLEDevice device);
List<BLEData> findAllByDeviceAndLastTimeBetweenOrderByLastTimeAsc(BLEDevice device, LocalDateTime start, LocalDateTime end);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import devkor.com.teamcback.domain.ble.entity.BLEData;
import devkor.com.teamcback.domain.ble.entity.BLEDevice;
import devkor.com.teamcback.domain.ble.entity.BLEstatus;
import devkor.com.teamcback.domain.ble.event.PlaceBecameVacantEvent;
import devkor.com.teamcback.domain.ble.repository.BLEDataRepository;
import devkor.com.teamcback.domain.ble.repository.BLEDeviceRepository;
import devkor.com.teamcback.domain.place.entity.Place;
Expand All @@ -18,7 +17,6 @@
import devkor.com.teamcback.global.response.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -36,7 +34,6 @@ public class BLEService {
private final BLEDeviceRepository bledeviceRepository;
private final BLEDataRepository bleDataRepository;
private final PlaceRepository placeRepository;
private final ApplicationEventPublisher eventPublisher;

// 평균 구해올 시간대 라벨
private static final int[] TIME_SLOTS = {7, 10, 13, 16, 19, 22};
Expand All @@ -49,11 +46,6 @@ public class BLEService {
@Transactional
public UpdateBLERes updateBLE(UpdateBLEReq updateBLEReq) {
BLEDevice bleDevice = bledeviceRepository.findByDeviceName(updateBLEReq.getDeviceName());
if (bleDevice == null) {
throw new GlobalException(ResultCode.NOT_FOUND_DEVICE_NAME);
}
BLEData previousData = bleDataRepository.findTopByDeviceOrderByLastTimeDescIdDesc(bleDevice)
.orElse(null);
int capacity = bleDevice.getCapacity();
int people = getBlEPeople(updateBLEReq.getLastCount(), bleDevice);
Comment on lines 48 to 50
double final_ratio = (double) people / capacity;
Expand All @@ -69,29 +61,9 @@ public UpdateBLERes updateBLE(UpdateBLEReq updateBLEReq) {
bleData.setLastTime(updateBLEReq.getLastTime());
bleDataRepository.save(bleData);

if (becameVacant(previousData, status) && bleDevice.getPlace() != null) {
eventPublisher.publishEvent(new PlaceBecameVacantEvent(
bleDevice.getPlace().getId(),
bleData.getId(),
bleData.getLastTime()
));
}

return new UpdateBLERes(bleData);
}

private boolean becameVacant(
BLEData previousData,
BLEstatus newStatus
) {
if (!BLEstatus.VACANT.equals(newStatus) || previousData == null) {
return false;
}

return BLEstatus.AVAILABLE.equals(previousData.getLastStatus())
|| BLEstatus.CROWDED.equals(previousData.getLastStatus());
}

private int getBlEPeople(int lastCount, BLEDevice bleDevice) {
if (bleDevice == null) throw new GlobalException(ResultCode.NOT_FOUND_DEVICE_NAME);
double ratio = bleDevice.getRatio();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,4 @@ List<Category> findCategoriesByUserAndLocationTypeAndLocationId(

@Query("SELECT c FROM Category c LEFT JOIN FETCH c.categoryBookmarkList WHERE c.user = :user")
List<Category> findByUser(@Param("user") User user);

@Query("""
SELECT DISTINCT c.user.userId FROM CategoryBookmark cb
JOIN cb.category c
JOIN cb.bookmark b
WHERE c.user IS NOT NULL AND b.locationType = :locationType AND b.locationId = :locationId
""")
List<Long> findDistinctUserIdsByLocationTypeAndLocationId(
@Param("locationType") LocationType locationType,
@Param("locationId") Long locationId
);
}

This file was deleted.

This file was deleted.

Loading