Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Dec 18, 2023
1 parent 910a5d0 commit ff6aef2
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 72 deletions.
28 changes: 14 additions & 14 deletions cmd/sncli/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {
output := c.String("output")

noteFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
}
getNotesIF := items.ItemFilters{
MatchAny: false,
Expand All @@ -319,7 +319,7 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {

if !c.Bool("include-trash") {
includeTrashFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Trash",
Comparison: "!=",
Value: "true",
Expand All @@ -329,7 +329,7 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {

if uuid != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "uuid",
Comparison: "==",
Value: uuid,
Expand All @@ -339,7 +339,7 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {

if title != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Title",
Comparison: "contains",
Value: title,
Expand All @@ -349,7 +349,7 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {

if text != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Text",
Comparison: "contains",
Value: text,
Expand All @@ -362,8 +362,8 @@ func processGetNotes(c *cli.Context, opts configOptsOutput) (err error) {
if len(processedTags) > 0 {
for _, t := range processedTags {
titleFilter := items.Filter{
Type: "Note",
Key: "Tag",
Type: common.SNItemTypeNote,
Key: common.SNItemTypeTag,
Comparison: "contains",
Value: t,
}
Expand Down Expand Up @@ -401,15 +401,15 @@ func processGetTrash(c *cli.Context, opts configOptsOutput) (err error) {
output := c.String("output")

noteFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
}
getNotesIF := items.ItemFilters{
MatchAny: false,
Filters: []items.Filter{noteFilter},
}

TrashFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Trash",
Comparison: "==",
Value: "true",
Expand All @@ -418,7 +418,7 @@ func processGetTrash(c *cli.Context, opts configOptsOutput) (err error) {

if uuid != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "uuid",
Comparison: "==",
Value: uuid,
Expand All @@ -428,7 +428,7 @@ func processGetTrash(c *cli.Context, opts configOptsOutput) (err error) {

if title != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Title",
Comparison: "contains",
Value: title,
Expand All @@ -438,7 +438,7 @@ func processGetTrash(c *cli.Context, opts configOptsOutput) (err error) {

if text != "" {
titleFilter := items.Filter{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Text",
Comparison: "contains",
Value: text,
Expand All @@ -451,8 +451,8 @@ func processGetTrash(c *cli.Context, opts configOptsOutput) (err error) {
if len(processedTags) > 0 {
for _, t := range processedTags {
titleFilter := items.Filter{
Type: "Note",
Key: "Tag",
Type: common.SNItemTypeNote,
Key: common.SNItemTypeTag,
Comparison: "contains",
Value: t,
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/sncli/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/jonhadfield/gosn-v2/common"
"os"
"strings"

Expand Down Expand Up @@ -78,7 +79,7 @@ func getTagsByTitle(sess cache.Session, title string) (tags items.Tags, err erro

var allEncTags cache.Items

query := so.DB.Select(q.And(q.Eq("ContentType", "Tag"), q.Eq("Deleted", false)))
query := so.DB.Select(q.And(q.Eq("ContentType", common.SNItemTypeTag), q.Eq("Deleted", false)))

err = query.Find(&allEncTags)
if err != nil {
Expand Down Expand Up @@ -224,7 +225,7 @@ func processGetTags(c *cli.Context, opts configOptsOutput) (err error) {
if inUUID != "" {
for _, uuid := range sncli.CommaSplit(inUUID) {
titleFilter := items.Filter{
Type: "Tag",
Type: common.SNItemTypeTag,
Key: "uuid",
Comparison: "==",
Value: uuid,
Expand All @@ -241,7 +242,7 @@ func processGetTags(c *cli.Context, opts configOptsOutput) (err error) {
if inTitle != "" {
for _, title := range sncli.CommaSplit(inTitle) {
titleFilter := items.Filter{
Type: "Tag",
Type: common.SNItemTypeTag,
Key: "Title",
Comparison: comparison,
Value: title,
Expand All @@ -252,7 +253,7 @@ func processGetTags(c *cli.Context, opts configOptsOutput) (err error) {

if inTitle == "" && inUUID == "" {
getTagsIF.Filters = append(getTagsIF.Filters, items.Filter{
Type: "Tag",
Type: common.SNItemTypeTag,
})
}

Expand Down
16 changes: 8 additions & 8 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package sncli
// require.NotEmpty(t, encItems[0].CreatedAtTimestamp)
// require.NotEmpty(t, encItems[0].CreatedAt)
// require.False(t, encItems[0].Deleted)
// require.Equal(t, "Note", encItems[0].ContentType)
// require.Equal(t, common.SNItemTypeNote, encItems[0].ContentType)
// require.NotEmpty(t, encItems[0].Content)
// require.Empty(t, encItems[0].DuplicateOf)
//
Expand All @@ -39,13 +39,13 @@ package sncli
// var dn items.Note
//
// for x := range pi {
// if pi[x].GetContentType() == "Note" {
// if pi[x].GetContentType() == common.SNItemTypeNote {
// dn = *pi[x].(*items.Note)
//
// }
// }
//
// require.Equal(t, "Note", dn.ContentType)
// require.Equal(t, common.SNItemTypeNote, dn.ContentType)
// require.Equal(t, "test title", dn.Content.GetTitle())
// require.Equal(t, "test content", dn.Content.GetText())
// require.NotEmpty(t, dn.UUID)
Expand Down Expand Up @@ -171,7 +171,7 @@ package sncli
// var importedNote cache.Item
//
// for _, i := range aa {
// if i.ContentType == "Note" {
// if i.ContentType == common.SNItemTypeNote {
// if i.UUID == note.UUID {
// importedNote = i
// }
Expand Down Expand Up @@ -282,7 +282,7 @@ package sncli
// var foundNote cache.Item
//
// for _, i := range aa {
// if i.ContentType == "Note" {
// if i.ContentType == common.SNItemTypeNote {
// if i.UUID == note.UUID {
// require.False(t, i.Deleted)
// foundNote = i
Expand Down Expand Up @@ -385,7 +385,7 @@ package sncli
// origFound = true
// }
//
// if x.ContentType == "Note" {
// if x.ContentType == common.SNItemTypeNote {
// if x.UUID != originalNote.UUID {
// newItemWithDupeIDBeingOrig = true
// }
Expand Down Expand Up @@ -514,7 +514,7 @@ package sncli
// var found bool
//
// for _, i := range gItems {
// if i.GetContentType() == "Tag" {
// if i.GetContentType() == common.SNItemTypeTag {
// if i.(*items.Tag).Equals(originalTag) {
// found = true
// }
Expand Down Expand Up @@ -654,7 +654,7 @@ package sncli
// var found bool
//
// for _, i := range gItems {
// if i.GetContentType() == "Tag" {
// if i.GetContentType() == common.SNItemTypeTag {
// if i.GetUUID() == originalTag.UUID {
// found = true
// }
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sncli

import (
"github.com/jonhadfield/gosn-v2/common"
"os"
"time"

Expand Down Expand Up @@ -292,7 +293,7 @@ func filterCacheItemsByTypes(ei cache.Items, types []string) (o cache.Items) {
return o
}

var supportedContentTypes = []string{"Note", "Tag", "SN|Component"}
var supportedContentTypes = []string{common.SNItemTypeNote, common.SNItemTypeTag, common.SNItemTypeComponent}

func (i *WipeConfig) Run() (int, error) {
i.Session.RemoveDB()
Expand Down
16 changes: 8 additions & 8 deletions note.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func addNote(i addNoteInput) (noteUUID string, err error) {
MatchAny: false,
Filters: []items.Filter{
{
Type: "Note",
Type: common.SNItemTypeNote,
Key: "Title",
Comparison: "==",
Value: i.noteTitle,
Expand Down Expand Up @@ -150,7 +150,7 @@ func addNote(i addNoteInput) (noteUUID string, err error) {

var allEncTags cache.Items

query := so.DB.Select(q.And(q.Eq("ContentType", "Tag"), q.Eq("Deleted", false)))
query := so.DB.Select(q.And(q.Eq("ContentType", common.SNItemTypeTag), q.Eq("Deleted", false)))

err = query.Find(&allEncTags)
// it's ok if there are no tags, so only error if something else went wrong
Expand Down Expand Up @@ -253,7 +253,7 @@ func deleteNotes(session *cache.Session, noteTitles []string, noteText string, n
Key: "Title",
Value: title,
Comparison: comparison,
Type: "Note",
Type: common.SNItemTypeNote,
})
}
case noteText != "":
Expand All @@ -266,15 +266,15 @@ func deleteNotes(session *cache.Session, noteTitles []string, noteText string, n
Key: "Text",
Value: noteText,
Comparison: comparison,
Type: "Note",
Type: common.SNItemTypeNote,
})
case len(noteUUIDs) > 0:
for _, uuid := range noteUUIDs {
getNotesFilters = append(getNotesFilters, items.Filter{
Key: "UUID",
Value: uuid,
Comparison: "==",
Type: "Note",
Type: common.SNItemTypeNote,
})
}
}
Expand Down Expand Up @@ -328,7 +328,7 @@ func deleteNotes(session *cache.Session, noteTitles []string, noteText string, n

if notesToDelete == nil || len(notesToDelete) == 0 {
// close db as we're not going to save anything
session.CacheDB.Close()
_ = session.CacheDB.Close()

return
}
Expand Down Expand Up @@ -365,7 +365,7 @@ func deleteItems(session *cache.Session, noteTitles []string, noteText string, i
Key: "Title",
Value: title,
Comparison: comparison,
Type: "Note",
Type: common.SNItemTypeNote,
})
}
case noteText != "":
Expand All @@ -378,7 +378,7 @@ func deleteItems(session *cache.Session, noteTitles []string, noteText string, i
Key: "Text",
Value: noteText,
Comparison: comparison,
Type: "Note",
Type: common.SNItemTypeNote,
})
case len(itemUUIDs) > 0:
for _, uuid := range itemUUIDs {
Expand Down
Loading

0 comments on commit ff6aef2

Please sign in to comment.