Skip to content

Commit

Permalink
feature/refetch: update branch (#249)
Browse files Browse the repository at this point in the history
* ui/overrides: show errors on user conflict (#182)

* show errors on failure for user overrides

* show field errors properly

* remove redundant icon props

* update userErrors array to be more understandable

* build(deps): bump @material-ui/core from 4.6.1 to 4.7.0 in /web/src (#217)

Bumps [@material-ui/core](https://github.com/mui-org/material-ui/tree/HEAD/packages/material-ui) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/mui-org/material-ui/releases)
- [Changelog](https://github.com/mui-org/material-ui/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mui-org/material-ui/commits/v4.7.0/packages/material-ui)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* ep repeat count never negative (#228)

* graphql: update gqlgen to v0.10.1 (#200)

* update gqlgen

* remove old alertlog.Entry interface

* rename rawentry -> entry.go

* update playground and set Referrer-Policy

* return validation error on CM not found

* set content-type on graphql requests

* set content-type in cypress graphql calls

* update direct deps

* build(deps-dev): bump cypress-plugin-retries in /web/src (#230)

Bumps [cypress-plugin-retries](https://github.com/Bkucera/cypress-plugin-retries) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/Bkucera/cypress-plugin-retries/releases)
- [Commits](kuceb/cypress-plugin-retries@v1.4.0...v1.5.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* dev: add Makefile commands for building CI test input (#229)

* add makefile commands for building test bundle

* always "bundle" dist binaries

* ui: remove memoize from urlParamSelector (#226)

* Fix bug in schedule shifts list to begin on current day

* ui: update @material-ui/lab and convert SpeedDial to hooks (#204)

* upgrade @hot-loader/react-dom @material-ui/core @material-ui/icons @types/luxon connected-react-router

* upgrade history luxon mdi-material-ui husky

* upgrade react react-dom react-ga react-router-dom terser-webpack-plugin ts-loader typescript webpack webpack-dev-server

* oops, forgot the lockfile

* WIP: convert speed dial to hooks, upgrade pkg

* style tooltip labels

* stop reversing every actions array

* update speed dial tests

* combine selectors

* upgrade @material-ui/lab

* bundle

* Revert "stop reversing every actions array"

This reverts commit 41cd2fe.

* remove comments of perplexion

* upgrade @material-ui/lab

* use the handle naming convention set by jsx-handler-names

* makeStyles with obj

* inline w anonymous funs

* build(deps-dev): bump @babel/cli from 7.7.0 to 7.7.4 in /web/src (#234)

Bumps [@babel/cli](https://github.com/babel/babel) from 7.7.0 to 7.7.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.7.0...v7.7.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* alerts: create alerts for multiple services at once (#173)

* don't use FormDialog for url-provided-error dialog

* getServiceLabel util & unit test

* add additional test cases

* new create alert flow

Co-Authored-By: Nathaniel Caza <[email protected]>

* ui/cypress: add retry plugin for console output in CI (#233)

* add retry plugin for console output in CI

* add plugin for CI

* smoketest/harness: ensure datagen always returns unique values (#237)

* build(deps-dev): bump @babel/plugin-syntax-dynamic-import in /web/src (#236)

Bumps [@babel/plugin-syntax-dynamic-import](https://github.com/babel/babel) from 7.2.0 to 7.7.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.2.0...v7.7.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump @babel/preset-react in /web/src (#235)

Bumps [@babel/preset-react](https://github.com/babel/babel) from 7.7.0 to 7.7.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.7.0...v7.7.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump @babel/plugin-transform-runtime in /web/src (#231)

Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel) from 7.6.2 to 7.7.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.6.2...v7.7.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump raw-loader from 3.1.0 to 4.0.0 in /web/src (#240)

Bumps [raw-loader](https://github.com/webpack-contrib/raw-loader) from 3.1.0 to 4.0.0.
- [Release notes](https://github.com/webpack-contrib/raw-loader/releases)
- [Changelog](https://github.com/webpack-contrib/raw-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/raw-loader@v3.1.0...v4.0.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* go: linting fixes (#242)

* run gofmt with -s

* fix spelling mistakes

* build(deps): bump connected-react-router from 6.6.0 to 6.6.1 in /web/src (#239)

Bumps [connected-react-router](https://github.com/supasate/connected-react-router) from 6.6.0 to 6.6.1.
- [Release notes](https://github.com/supasate/connected-react-router/releases)
- [Commits](supasate/connected-react-router@v6.6.0...v6.6.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps): bump mdi-material-ui from 6.8.0 to 6.9.0 in /web/src (#245)

Bumps [mdi-material-ui](https://github.com/TeamWertarbyte/mdi-material-ui) from 6.8.0 to 6.9.0.
- [Release notes](https://github.com/TeamWertarbyte/mdi-material-ui/releases)
- [Commits](TeamWertarbyte/mdi-material-ui@v6.8.0...v6.9.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* go: update direct deps (#252)

* update direct deps

* run tidy

* build(deps): bump @material-ui/core from 4.7.0 to 4.7.1 in /web/src (#248)

Bumps [@material-ui/core](https://github.com/mui-org/material-ui/tree/HEAD/packages/material-ui) from 4.7.0 to 4.7.1.
- [Release notes](https://github.com/mui-org/material-ui/releases)
- [Changelog](https://github.com/mui-org/material-ui/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mui-org/material-ui/commits/v4.7.1/packages/material-ui)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* dependabot: config (#253)

* update direct deps

* run tidy

* ignoring cypress 3.7.0

* build(deps-dev): bump @babel/plugin-proposal-class-properties (#255)

Bumps [@babel/plugin-proposal-class-properties](https://github.com/babel/babel) from 7.7.0 to 7.7.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.7.0...v7.7.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* schedule/rotation: fix endtime calculation bug (#254)

* handle future start time in Rotation.EndTime method

* add unit test for rotation future start time

* remove old redundant comments

* ui/profile: prevent adding a notification rule if there are no contact methods (#251)

* Disable Add Notification Rule speed dial option if there are no Contact Methods

* build(deps-dev): bump style-loader from 1.0.0 to 1.0.1 in /web/src (#256)

Bumps [style-loader](https://github.com/webpack-contrib/style-loader) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/webpack-contrib/style-loader/releases)
- [Changelog](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/style-loader@v1.0.0...v1.0.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps): bump github.com/spf13/viper from 1.5.0 to 1.6.1 (#258)

Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](spf13/viper@v1.5.0...v1.6.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump eslint from 6.6.0 to 6.7.2 in /web/src (#257)

Bumps [eslint](https://github.com/eslint/eslint) from 6.6.0 to 6.7.2.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v6.6.0...v6.7.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* twilio : make voice verification calls more user-friendly (#260)

* pause and delays between digits

* verbose message for voice verification codes

* increase timeout for voice message responses

* build(deps-dev): bump eslint-plugin-react in /web/src (#262)

Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.16.0 to 7.17.0.
- [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases)
- [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](jsx-eslint/eslint-plugin-react@v7.16.0...v7.17.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps): bump @material-ui/lab in /web/src (#259)

Bumps [@material-ui/lab](https://github.com/mui-org/material-ui/tree/HEAD/packages/material-ui-lab) from 4.0.0-alpha.33 to 4.0.0-alpha.35.
- [Release notes](https://github.com/mui-org/material-ui/releases)
- [Changelog](https://github.com/mui-org/material-ui/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mui-org/material-ui/commits/HEAD/packages/material-ui-lab)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* ui/profile: added '+' as input adornment to phone field for contact method (#263)

* added cm '+' adornment

* build(deps-dev): bump file-loader from 4.3.0 to 5.0.2 in /web/src (#238)

* build(deps-dev): bump file-loader from 4.3.0 to 5.0.2 in /web/src

Bumps [file-loader](https://github.com/webpack-contrib/file-loader) from 4.3.0 to 5.0.2.
- [Release notes](https://github.com/webpack-contrib/file-loader/releases)
- [Changelog](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/file-loader@v4.3.0...v5.0.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump file-loader from 4.3.0 to 5.0.2 in /web/src

Bumps [file-loader](https://github.com/webpack-contrib/file-loader) from 4.3.0 to 5.0.2.
- [Release notes](https://github.com/webpack-contrib/file-loader/releases)
- [Changelog](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/file-loader@v4.3.0...v5.0.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump file-loader from 4.3.0 to 5.0.2 in /web/src

Bumps [file-loader](https://github.com/webpack-contrib/file-loader) from 4.3.0 to 5.0.2.
- [Release notes](https://github.com/webpack-contrib/file-loader/releases)
- [Changelog](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/file-loader@v4.3.0...v5.0.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* require logo -> import logo

* requires -> imports

* cypress: use whitelist instead of preserveOnce (#268)

* build(deps-dev): bump eslint-plugin-import in /web/src (#267)

Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.18.2 to 2.19.1.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](import-js/eslint-plugin-import@v2.18.2...v2.19.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* cypress: increase timeout threshold for creating schedule (#264)

* build(deps): bump luxon from 1.21.2 to 1.21.3 in /web/src (#266)

Bumps [luxon](https://github.com/moment/luxon) from 1.21.2 to 1.21.3.
- [Release notes](https://github.com/moment/luxon/releases)
- [Changelog](https://github.com/moment/luxon/blob/master/changelog.md)
- [Commits](moment/luxon@1.21.2...1.21.3)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* build(deps-dev): bump @babel/core from 7.7.2 to 7.7.5 in /web/src (#265)

Bumps [@babel/core](https://github.com/babel/babel) from 7.7.2 to 7.7.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.7.2...v7.7.5)

Signed-off-by: dependabot-preview[bot] <[email protected]>
  • Loading branch information
Forfold authored Dec 12, 2019
1 parent 0ee409a commit 7ab76bb
Show file tree
Hide file tree
Showing 91 changed files with 6,473 additions and 2,882 deletions.
2 changes: 1 addition & 1 deletion .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ update_configs:
ignored_updates:
- match:
dependency_name: "cypress"
version_requirement: "<=3.6.1"
version_requirement: "<=3.7.0"
- match:
dependency_name: "react-infinite-scroll-component"
version_requirement: "<=5.0.3"
Expand Down
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,72 @@ $(BIN_DIR)/resetdb: go.sum devtools/resetdb/*.go migrate/*.go
go build $(BUILD_FLAGS) -o $@ ./devtools/$(@F)
$(BIN_DIR)/mockslack: go.sum $(shell find ./devtools/mockslack -name '*.go')
go build $(BUILD_FLAGS) -o $@ ./devtools/mockslack/cmd/mockslack

$(BIN_DIR)/runjson.linux: go.sum devtools/runjson/*.go
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/$(basename $(@F))
$(BIN_DIR)/psql-lite.linux: go.sum devtools/psql-lite/*.go
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/$(basename $(@F))
$(BIN_DIR)/waitfor.linux: go.sum devtools/waitfor/*.go
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/$(basename $(@F))
$(BIN_DIR)/simpleproxy.linux: go.sum devtools/simpleproxy/*.go
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/$(basename $(@F))
$(BIN_DIR)/resetdb.linux: go.sum devtools/resetdb/*.go migrate/*.go
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/$(basename $(@F))
$(BIN_DIR)/mockslack.linux: go.sum $(shell find ./devtools/mockslack -name '*.go')
GOOS=linux go build $(BUILD_FLAGS) -o $@ ./devtools/mockslack/cmd/mockslack

$(BIN_DIR)/goalert: go.sum $(GOFILES) graphql2/mapconfig.go
go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" -ldflags "$(LD_FLAGS)" -o $@ ./cmd/goalert
$(BIN_DIR)/goalert.linux: $(BIN_DIR)/goalert web/inline_data_gen.go
GOOS=linux go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" -ldflags "$(LD_FLAGS)" -o $@ ./cmd/goalert
$(BIN_DIR)/goalert.darwin: $(BIN_DIR)/goalert web/inline_data_gen.go
GOOS=darwin go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" -ldflags "$(LD_FLAGS)" -o $@ ./cmd/goalert

$(BIN_DIR)/goalert-linux-amd64.tgz: $(BIN_DIR)/goalert.linux
rm -rf bin/goalert-linux
mkdir -p bin/goalert-linux/goalert/bin
cp $(BIN_DIR)/goalert.linux bin/goalert-linux/goalert/bin/goalert
tar czvf $@ -C bin/goalert-linux goalert

$(BIN_DIR)/goalert-darwin-amd64.tgz: $(BIN_DIR)/goalert.darwin
rm -rf bin/goalert-darwin
mkdir -p bin/goalert-darwin/goalert/bin
cp $(BIN_DIR)/goalert.darwin bin/goalert-darwin/goalert/bin/goalert
tar czvf $@ -C bin/goalert-darwin goalert

$(BIN_DIR)/integration/goalert/cypress.json: web/src/cypress.json
sed 's/\.ts/\.js/' web/src/cypress.json >bin/integration/goalert/cypress.json

$(BIN_DIR)/integration/goalert/cypress: web/src/node_modules web/src/webpack.cypress.js $(BIN_DIR)/integration/goalert/cypress.json $(shell find ./web/src/cypress)
rm -rf $@
(cd web/src && yarn webpack --config webpack.cypress.js --target node)
cp -r web/src/cypress/fixtures bin/integration/goalert/cypress/
touch $@

$(BIN_DIR)/integration/goalert/bin: $(BIN_DIR)/goalert.linux $(BIN_DIR)/mockslack.linux $(BIN_DIR)/simpleproxy.linux $(BIN_DIR)/waitfor.linux $(BIN_DIR)/runjson.linux $(BIN_DIR)/psql-lite.linux
rm -rf $@
mkdir -p bin/integration/goalert/bin
cp bin/*.linux bin/integration/goalert/bin/
for f in bin/integration/goalert/bin/*.linux; do mv $$f bin/integration/goalert/bin/$$(basename $$f .linux); done
touch $@

$(BIN_DIR)/integration/goalert/devtools: $(shell find ./devtools/ci)
rm -rf $@
mkdir -p bin/integration/goalert/devtools
cp -r devtools/ci bin/integration/goalert/devtools/
touch $@

$(BIN_DIR)/integration/goalert/.git: $(shell find ./.git)
rm -rf $@
mkdir -p bin/integration/goalert/.git
git rev-parse HEAD >bin/integration/goalert/COMMIT
test -d .git/resource && cp -r .git/resource bin/integration/goalert/.git/ || true

$(BIN_DIR)/integration: $(BIN_DIR)/integration/goalert/.git $(BIN_DIR)/integration/goalert/devtools $(BIN_DIR)/integration/goalert/cypress $(BIN_DIR)/integration/goalert/bin
touch $@

$(BIN_DIR)/integration.tgz: bin/integration
tar czvf bin/integration.tgz -C bin/integration goalert

install: $(GOFILES)
go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS)" -ldflags "$(LD_FLAGS)" ./cmd/goalert
Expand Down
174 changes: 159 additions & 15 deletions alert/log/entry.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,171 @@
package alertlog

import (
"context"
"database/sql"
"encoding/json"
"fmt"
"time"

"github.com/target/goalert/util/log"
)

// An Entry is an alert log entry.
type Entry interface {
// AlertID returns the ID of the alert the Entry belongs to.
AlertID() int
type Entry struct {
id int
alertID int
timestamp time.Time
_type Type
message string
subject struct {
_type SubjectType
userID sql.NullString
userName sql.NullString
integrationKeyID sql.NullString
integrationKeyName sql.NullString
heartbeatMonitorID sql.NullString
heartbeatMonitorName sql.NullString
channelID sql.NullString
channelName sql.NullString
classifier string
}
meta rawJSON
}

func (e Entry) Meta() interface{} {
switch e.Type() {
case TypeEscalated:
var esc EscalationMetaData
err := json.Unmarshal(e.meta, &esc)
if err != nil {
log.Debug(context.Background(), err)
return nil
}
return &esc
}

return nil
}
func (e Entry) AlertID() int {
return e.alertID
}

func (e Entry) ID() int {
return e.id
}

func (e Entry) Timestamp() time.Time {
return e.timestamp
}
func (e Entry) Type() Type {
switch e._type {
case _TypeResponseReceived:
return respRecvType(e.message)
case _TypeStatusChanged:
return statChgType(e.message)
}

return e._type
}

func (e Entry) Subject() *Subject {
if e.subject._type == SubjectTypeNone {
if e.message != "" {
return e.subjectFromMessage()
}
return nil
}

s := &Subject{
Type: e.subject._type,
Classifier: e.subject.classifier,
}

switch s.Type {
case SubjectTypeUser:
s.ID = e.subject.userID.String
s.Name = e.subject.userName.String
case SubjectTypeIntegrationKey:
s.ID = e.subject.integrationKeyID.String
s.Name = e.subject.integrationKeyName.String
case SubjectTypeHeartbeatMonitor:
s.ID = e.subject.heartbeatMonitorID.String
s.Name = e.subject.heartbeatMonitorName.String
case SubjectTypeChannel:
s.ID = e.subject.channelID.String
s.Name = e.subject.channelName.String
}

// ID returns the ID of the log entry.
ID() int
// Timestamp returns the time the Entry was created.
Timestamp() time.Time
return s
}

func escalationMsg(m *EscalationMetaData) string {
msg := fmt.Sprintf(" to step #%d", m.NewStepIndex+1)
if m.Repeat {
msg += " (policy repeat)"
}
if m.Forced {
msg += " due to manual escalation"
} else if m.Deleted {
msg += " due to current step being deleted"
} else if m.OldDelayMinutes > 0 {
msg += fmt.Sprintf(" automatically after %d minutes", m.OldDelayMinutes)
}

// Type returns type type of log entry.
Type() Type
return msg
}

// Subject will return the subject, if available of the Entry.
Subject() *Subject
func (e Entry) String() string {
var msg string
var infinitive bool
switch e.Type() {
case TypeCreated:
msg = "Created"
case TypeAcknowledged:
msg = "Acknowledged"
case TypeClosed:
msg = "Closed"
case TypeEscalated:
msg = "Escalated"
meta, ok := e.Meta().(*EscalationMetaData)
if ok {
msg += escalationMsg(meta)
}
case TypeNotificationSent:
msg = "Notification sent"
infinitive = true
case TypePolicyUpdated:
msg = "Policy updated"
case TypeDuplicateSupressed:
msg = "Suppressed duplicate: created"
case TypeEscalationRequest:
msg = "Escalation requested"
default:
return "Error"
}

// String returns the string representation of a log Event.
String() string
// include subject, if available
msg += subjectString(infinitive, e.Subject())

return msg
}

Meta() interface{}
func (e *Entry) scanWith(scan func(...interface{}) error) error {
return scan(
&e.id,
&e.alertID,
&e.timestamp,
&e._type,
&e.message,
&e.subject._type,
&e.subject.userID,
&e.subject.userName,
&e.subject.integrationKeyID,
&e.subject.integrationKeyName,
&e.subject.heartbeatMonitorID,
&e.subject.heartbeatMonitorName,
&e.subject.channelID,
&e.subject.channelName,
&e.subject.classifier,
&e.meta,
)
}
2 changes: 1 addition & 1 deletion alert/log/legacylogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
)

func (e *rawEntry) subjectFromMessage() *Subject {
func (e *Entry) subjectFromMessage() *Subject {
switch e._type {
case TypeCreated:
return createdSubject(e.message)
Expand Down
15 changes: 5 additions & 10 deletions alert/log/legacysearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import (
"context"
"database/sql"
"fmt"
"github.com/target/goalert/util/sqlutil"
"time"

"github.com/pkg/errors"
"github.com/target/goalert/permission"
"github.com/target/goalert/search"
"github.com/target/goalert/util/sqlutil"
"github.com/target/goalert/validation"
"github.com/target/goalert/validation/validate"

"github.com/pkg/errors"
)

// LegacySearchOptions contains criteria for filtering alert logs. At a minimum, at least one of AlertID or ServiceID must be specified.
Expand Down Expand Up @@ -213,21 +212,17 @@ func (db *DB) LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]En
}
defer rows.Close()

var result []rawEntry
var result []Entry

for rows.Next() {
var r rawEntry
var r Entry
err = r.scanWith(rows.Scan)
if err != nil {
return nil, 0, err
}
result = append(result, r)
}
var logs []Entry
for _, e := range result {
logs = append(logs, e)
}

return logs, total, nil
return result, total, nil

}
Loading

0 comments on commit 7ab76bb

Please sign in to comment.