Skip to content

Commit

Permalink
fix: unify time range end time if fake 3939 is used in drop matrix an…
Browse files Browse the repository at this point in the history
…d pattern matrix calc
  • Loading branch information
AlvISsReimu committed Jun 6, 2022
1 parent 182415b commit ed060ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/service/drop_matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ func (s *DropMatrix) getDropMatrixElements(ctx context.Context, server string, a
func (s *DropMatrix) calcDropMatrixForTimeRanges(
ctx context.Context, server string, timeRanges []*model.TimeRange, stageIdFilter []int, itemIdFilter []int, accountId null.Int, sourceCategory string,
) ([]*model.DropMatrixElement, error) {
// For one time range whose end time is FakeEndTimeMilli, we will make separate query to get times, quantity and quantity buckets.
// We need to make sure they are queried based on the same set of drop reports. So we will use a unified end time instead of FakeEndTimeMilli.
unifiedEndTime := time.Now()
for _, timeRange := range timeRanges {
if timeRange.EndTime.After(unifiedEndTime) {
timeRange.EndTime = &unifiedEndTime
}
}

dropInfos, err := s.DropInfoService.GetDropInfosWithFilters(ctx, server, timeRanges, stageIdFilter, itemIdFilter)
if err != nil {
return nil, err
Expand Down
9 changes: 9 additions & 0 deletions internal/service/pattern_matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ func (s *PatternMatrix) calcPatternMatrixForTimeRanges(
) ([]*model.PatternMatrixElement, error) {
results := make([]*model.PatternMatrixElement, 0)

// For one time range whose end time is FakeEndTimeMilli, we will make separate query to get times and quantity.
// We need to make sure they are queried based on the same set of drop reports. So we will use a unified end time instead of FakeEndTimeMilli.
unifiedEndTime := time.Now()
for _, timeRange := range timeRanges {
if timeRange.EndTime.After(unifiedEndTime) {
timeRange.EndTime = &unifiedEndTime
}
}

dropInfos, err := s.DropInfoService.GetDropInfosWithFilters(ctx, server, timeRanges, stageIdFilter, nil)
if err != nil {
return nil, err
Expand Down

0 comments on commit ed060ae

Please sign in to comment.