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
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@
@RequiredArgsConstructor
public class CommonController {

// 간단한 기능이기에 바로 repository를 사용합니다.
private final AdminMemberRepository adminMemberRepository;
private final AdminSpaceRepository adminSpaceRepository;
private final AdminRetrospectHistoryRepository adminRetrospectHistoryRepository;
private final AdminRetrospectAnswerRepository adminRetrospectAnswerRepository;


@GetMapping("/admin/outline")
public ResponseEntity<OutlineResponse> getOutline() {

return ResponseEntity.ok(
new OutlineResponse(
adminMemberRepository.count(),
adminSpaceRepository.count(),
adminRetrospectHistoryRepository.count(),
adminRetrospectAnswerRepository.count()
adminMemberRepository.countExcluding(ExcludedMembers.ID_LIST),
adminSpaceRepository.countExcluding(ExcludedMembers.ID_LIST),
adminRetrospectHistoryRepository.countExcluding(ExcludedMembers.ID_LIST),
adminRetrospectAnswerRepository.countExcluding(ExcludedMembers.ID_LIST)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ List<Long> findMemberIdsByEventTimeBetween(
@Param("endTime") LocalDateTime endTime,
@Param("excludedIds") Collection<Long> excludedIds
);

@Query("SELECT COUNT(a) FROM AdminMemberSignupHistory a WHERE a.memberId NOT IN :excludedIds")
long countExcluding(@Param("excludedIds") Collection<Long> excludedIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ long countDistinctRetrospectIdByAnswerEndTimeBetween(
@Param("start") LocalDateTime start,
@Param("end") LocalDateTime end,
@Param("excludedIds") Collection<Long> excludedIds);

@Query("SELECT COUNT(a) FROM AdminRetrospectAnswerHistory a WHERE a.memberId NOT IN :excludedIds")
long countExcluding(@Param("excludedIds") Collection<Long> excludedIds);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.layer.admin.retrospect.repository;

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

import org.layer.admin.retrospect.entity.AdminRetrospectHistory;
Expand All @@ -23,6 +24,6 @@ List<SpaceRetrospectCountDto> findRetrospectCountGroupedBySpaceWithPeriod(
@Param("endTime") LocalDateTime endTime
);



@Query("SELECT COUNT(a) FROM AdminRetrospectHistory a WHERE a.memberId NOT IN :excludedIds")
long countExcluding(@Param("excludedIds") Collection<Long> excludedIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public CumulativeRetrospectCountResponse getCumulativeRetrospectCount(
.mapToLong(SpaceRetrospectCountDto::count)
.sum();

Long totalSpaceCount = adminSpaceRepository.countAllByEventTimeBetween(startTime, endTime);
Long totalSpaceCount = adminSpaceRepository.countAllByEventTimeBetween(startTime, endTime, ExcludedMembers.ID_LIST);
double averageCumulativeCount = totalSpaceCount == 0 ? 0.0 : (double)totalRetrospectCount / totalSpaceCount;
return new CumulativeRetrospectCountResponse(averageCumulativeCount);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.layer.admin.space.repository;

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

import org.layer.admin.space.entity.AdminMemberSpaceRelation;
Expand All @@ -18,10 +19,12 @@ public interface AdminMemberSpaceRelationRepository extends JpaRepository<AdminM
)
FROM AdminMemberSpaceRelation r
WHERE r.createdAt >= :startDate
AND r.memberId NOT IN :excludedIds
GROUP BY r.spaceId
""")
List<ProceedingSpaceDto> findProceedingSpacesWithMemberCount(
@Param("startDate") LocalDateTime startDate
@Param("startDate") LocalDateTime startDate,
@Param("excludedIds") Collection<Long> excludedIds
);

@Query("SELECT m FROM AdminMemberSpaceRelation m WHERE m.spaceId IN :spaceIds")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@ public interface AdminSpaceRepository
@Query("SELECT new org.layer.admin.space.controller.dto.SpaceCountResponse(a.category, COUNT(a)) " +
"FROM AdminSpaceHistory a " +
"WHERE a.eventTime BETWEEN :startTime AND :endTime " +
"AND a.memberId NOT IN :excludedIds " +
"GROUP BY a.category")
List<SpaceCountResponse> findAllByCategory(
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime
@Param("endTime") LocalDateTime endTime,
@Param("excludedIds") Collection<Long> excludedIds
);

@Query("SELECT COUNT(a) FROM AdminSpaceHistory a " +
"WHERE a.eventTime BETWEEN :startTime AND :endTime")
"WHERE a.eventTime BETWEEN :startTime AND :endTime " +
"AND a.memberId NOT IN :excludedIds")
Long countAllByEventTimeBetween(
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime);
@Param("endTime") LocalDateTime endTime,
@Param("excludedIds") Collection<Long> excludedIds);

@Query("SELECT COUNT(a) FROM AdminSpaceHistory a WHERE a.memberId NOT IN :excludedIds")
long countExcluding(@Param("excludedIds") Collection<Long> excludedIds);

List<AdminSpaceHistory> findAllBySpaceIdIn(Collection<Long> spaceIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class AdminSpaceService {
private final AdminMemberSpaceRelationRepository adminMemberSpaceRelationRepository;

public List<SpaceCountResponse> getSpaceCount(LocalDateTime startDate, LocalDateTime endDate) {
return adminSpaceRepository.findAllByCategory(startDate, endDate);
return adminSpaceRepository.findAllByCategory(startDate, endDate, ExcludedMembers.ID_LIST);
}

public TeamSpaceRatioResponse getAverageTeamSpaceRatioPerMember(
Expand Down Expand Up @@ -114,7 +114,7 @@ public SpaceAbandonRate calculateAbandonRate(LocalDateTime startDate, LocalDateT

List<Long> proceedingSpaceIds = adminRetrospectRepository.findProceedingSpacesByMember(startDate, endDate);

Map<Long, Long> spaceMemberCountMap = adminMemberSpaceRelationRepository.findProceedingSpacesWithMemberCount(startDate)
Map<Long, Long> spaceMemberCountMap = adminMemberSpaceRelationRepository.findProceedingSpacesWithMemberCount(startDate, ExcludedMembers.ID_LIST)
.stream()
.collect(Collectors.toMap(
ProceedingSpaceDto::spaceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.layer.admin.template.repository;

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

import org.layer.admin.template.controller.dto.TemplateChoiceCountResponse;
Expand All @@ -16,19 +17,23 @@ public interface AdminTemplateChoiceRepository extends JpaRepository<AdminTempla
"FROM AdminTemplateChoice r " +
"WHERE r.eventTime BETWEEN :startTime AND :endTime " +
"AND r.choiceType = :choiceType " +
"AND r.memberId NOT IN :excludedIds " +
"GROUP BY r.formTag")
List<TemplateChoiceCountResponse> countByChoiceType(
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime,
@Param("choiceType") AdminChoiceType choiceType
@Param("choiceType") AdminChoiceType choiceType,
@Param("excludedIds") Collection<Long> excludedIds
);

@Query("SELECT new org.layer.admin.template.controller.dto.TemplateChoiceCountResponse(r.formTag, COUNT(r)) " +
"FROM AdminTemplateChoice r " +
"WHERE r.eventTime BETWEEN :startTime AND :endTime " +
"AND r.memberId NOT IN :excludedIds " +
"GROUP BY r.formTag")
List<TemplateChoiceCountResponse> countAll(
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime
@Param("endTime") LocalDateTime endTime,
@Param("excludedIds") Collection<Long> excludedIds
);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package org.layer.admin.template.repository;

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

import org.layer.admin.template.controller.dto.TemplateClickCountResponse;
import org.layer.admin.template.entity.AdminTemplateClickHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface AdminTemplateClickHistoryRepository extends JpaRepository<AdminTemplateClickHistory, Long> {
@Query("SELECT new org.layer.admin.template.controller.dto.TemplateClickCountResponse(v.viewType, COUNT(v)) " +
"FROM AdminTemplateClickHistory v " +
"WHERE v.eventTime BETWEEN :startDate AND :endDate " +
"AND v.memberId NOT IN :excludedIds " +
"GROUP BY v.viewType ")
List<TemplateClickCountResponse> countByViewType(LocalDateTime startDate, LocalDateTime endDate);
List<TemplateClickCountResponse> countByViewType(
LocalDateTime startDate,
LocalDateTime endDate,
@Param("excludedIds") Collection<Long> excludedIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.time.LocalDateTime;
import java.util.List;

import org.layer.admin.common.ExcludedMembers;
import org.layer.admin.template.controller.dto.TemplateChoiceCountResponse;
import org.layer.admin.template.controller.dto.TemplateClickCountResponse;
import org.layer.admin.template.entity.AdminTemplateChoice;
Expand Down Expand Up @@ -35,16 +36,16 @@ public List<TemplateChoiceCountResponse> getTemplateChoiceCount(
LocalDateTime startDate, LocalDateTime endDate, AdminChoiceType choiceType) {

if (choiceType != null) {
return templateChoiceRepository.countByChoiceType(startDate, endDate, choiceType);
return templateChoiceRepository.countByChoiceType(startDate, endDate, choiceType, ExcludedMembers.ID_LIST);
}

return templateChoiceRepository.countAll(startDate, endDate);
return templateChoiceRepository.countAll(startDate, endDate, ExcludedMembers.ID_LIST);
}

public List<TemplateClickCountResponse> getTemplateClickCount(
LocalDateTime startDate, LocalDateTime endDate) {

return templateClickHistoryRepository.countByViewType(startDate, endDate);
return templateClickHistoryRepository.countByViewType(startDate, endDate, ExcludedMembers.ID_LIST);
}

@Transactional(propagation = REQUIRES_NEW)
Expand Down
Loading