Skip to content

Commit

Permalink
Go fumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
Koustavd18 committed Aug 6, 2024
1 parent e85f091 commit 4d0396b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
3 changes: 2 additions & 1 deletion cmd/filterList.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package cmd
import (
"fmt"
"os"
"pb/pkg/model"
"strings"
"time"

"pb/pkg/model"

"github.com/spf13/cobra"
)

Expand Down
17 changes: 8 additions & 9 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
"fmt"
"io"
"os"
"pb/pkg/config"
// "pb/pkg/model"
"strings"
"time"

"pb/pkg/config"
// "pb/pkg/model"

//! This dependancy is required by the interactive flag Do not remove
// tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
Expand All @@ -41,7 +43,7 @@ var (
// save filter flags
saveFilterFlag = "save-as"
saveFilterShort = "s"
//save filter with time flags
// save filter with time flags
saveFilterTimeFlag = "with-time"
saveFilterTimeShort = "w"

Expand All @@ -66,7 +68,7 @@ var query = &cobra.Command{
fmt.Printf("Example:\n pb query run \"select * from frontend\" --from=10m --to=now\n")

Check failure on line 68 in cmd/query.go

View workflow job for this annotation

GitHub Actions / build

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
return nil
}

query = args[0]

start, err := command.Flags().GetString(startFlag)
Expand All @@ -85,7 +87,7 @@ var query = &cobra.Command{
end = defaultEnd
}

//TODO: Interactive Flag disabled
// TODO: Interactive Flag disabled
// interactive, err := command.Flags().GetBool(interactiveFlag)
// if err != nil {
// return err
Expand All @@ -107,7 +109,7 @@ var query = &cobra.Command{
}
filterNameTrimmed := strings.Trim(filterName, " ")

//TODO: Interactive Flag disabled
// TODO: Interactive Flag disabled
// if interactive {
// p := tea.NewProgram(model.NewQueryModel(DefaultProfile, query, startTime, endTime), tea.WithAltScreen())
// if _, err := p.Run(); err != nil {
Expand All @@ -126,7 +128,6 @@ var query = &cobra.Command{
} else if filterName != "" {
if keepTime {
createFilterWithTime(query, filterNameTrimmed, start, end)

} else {
// if there is no keep time filter pass empty values for startTime and endTime
createFilter(query, filterNameTrimmed)
Expand Down Expand Up @@ -211,7 +212,6 @@ func parseTime(start, end string) (time.Time, time.Time, error) {

// create a request body for saving filter without time_filter
func createFilter(query string, filterName string) (err error) {

userConfig, err := config.ReadConfigFromFile()
if err != nil {
return err
Expand Down Expand Up @@ -250,7 +250,6 @@ func createFilter(query string, filterName string) (err error) {
saveFilterToServer(finalQuery)

return err

}

// create a request body for saving filter with time_filter
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"errors"
"os"

"pb/cmd"
"pb/pkg/config"

Expand Down Expand Up @@ -142,7 +143,7 @@ func main() {
}
config.WriteConfigToFile(&conf)
} else {
//updates the demo profile for existing users
// updates the demo profile for existing users
_, exists := previousConfig.Profiles["demo"]
if exists {
conf := config.Config{
Expand Down
13 changes: 6 additions & 7 deletions pkg/model/savedFilters.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"fmt"
"io"
"net/http"
"pb/pkg/config"
"strings"
"time"

"pb/pkg/config"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -116,8 +117,10 @@ func (d itemDelegate) FullHelp() [][]key.Binding {
}
}

var selectedFilterApply item
var selectedFilterDelete item
var (
selectedFilterApply item
selectedFilterDelete item
)

func (i item) Title() string { return fmt.Sprintf("Filter:%s, Query:%s", i.title, i.desc) }

Expand Down Expand Up @@ -173,7 +176,6 @@ func (m modelFilter) View() string {

// Interactive list for the user to display all the available filters (only saved SQL filters )
func UiApp() *tea.Program {

userConfig, err := config.ReadConfigFromFile()
if err != nil {
fmt.Println("Error reading Default Profile")
Expand All @@ -192,12 +194,10 @@ func UiApp() *tea.Program {
m.list.Title = fmt.Sprintf("Saved Filters for User: %s", userProfile.Username)

return tea.NewProgram(m, tea.WithAltScreen())

}

// fetchFilters fetches filters from the server and sends them to the channel
func fetchFilters(client *http.Client, profile *config.Profile) []list.Item {

endpoint := fmt.Sprintf("%s/%s/%s", profile.URL, "api/v1/filters", profile.Username)
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
Expand Down Expand Up @@ -253,7 +253,6 @@ func fetchFilters(client *http.Client, profile *config.Profile) []list.Item {
}
}
return userFilters

}

// returns the selected filter by user in the iteractive list
Expand Down

0 comments on commit 4d0396b

Please sign in to comment.