diff --git a/core/block/detailservice/relations.go b/core/block/detailservice/relations.go index 8a62447dc..b9eea05ee 100644 --- a/core/block/detailservice/relations.go +++ b/core/block/detailservice/relations.go @@ -18,7 +18,7 @@ import ( coresb "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock" "github.com/anyproto/anytype-heart/pkg/lib/database" "github.com/anyproto/anytype-heart/space/spacecore/typeprovider" - "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/pbtypes" "github.com/anyproto/anytype-heart/util/slice" ) @@ -114,7 +114,7 @@ func generateFilter(value *types.Value) func(v *types.Value) bool { return equalFilter } - start, err := date.ParseDateId(stringValue) + start, err := dateutil.ParseDateId(stringValue) if err != nil { log.Error("failed to convert date id to day start", zap.Error(err)) return equalFilter diff --git a/core/block/detailservice/relations_test.go b/core/block/detailservice/relations_test.go index 33c73b6b0..45adb6bcf 100644 --- a/core/block/detailservice/relations_test.go +++ b/core/block/detailservice/relations_test.go @@ -16,7 +16,7 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/bundle" "github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" - "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/pbtypes" ) @@ -57,7 +57,7 @@ func TestService_ListRelationsWithValue(t *testing.T) { { bundle.RelationKeyId: pbtypes.String("obj2"), bundle.RelationKeySpaceId: pbtypes.String(spaceId), - bundle.RelationKeyName: pbtypes.String(date.TimeToDateId(now)), + bundle.RelationKeyName: pbtypes.String(dateutil.TimeToDateId(now)), bundle.RelationKeyCreatedDate: pbtypes.Int64(now.Add(-24*time.Hour - 5*time.Minute).Unix()), bundle.RelationKeyAddedDate: pbtypes.Int64(now.Add(-24*time.Hour - 3*time.Minute).Unix()), bundle.RelationKeyLastModifiedDate: pbtypes.Int64(now.Add(-1 * time.Minute).Unix()), @@ -84,13 +84,13 @@ func TestService_ListRelationsWithValue(t *testing.T) { }{ { "date object - today", - pbtypes.String(date.TimeToDateId(now)), + pbtypes.String(dateutil.TimeToDateId(now)), []string{bundle.RelationKeyAddedDate.String(), bundle.RelationKeyCreatedDate.String(), bundle.RelationKeyLastModifiedDate.String(), bundle.RelationKeyName.String()}, []int64{1, 2, 3, 1}, }, { "date object - yesterday", - pbtypes.String(date.TimeToDateId(now.Add(-24 * time.Hour))), + pbtypes.String(dateutil.TimeToDateId(now.Add(-24 * time.Hour))), []string{bundle.RelationKeyAddedDate.String(), bundle.RelationKeyCreatedDate.String()}, []int64{1, 1}, }, diff --git a/core/block/import/notion/api/block/textobject.go b/core/block/import/notion/api/block/textobject.go index 542558c3c..c0466c6d4 100644 --- a/core/block/import/notion/api/block/textobject.go +++ b/core/block/import/notion/api/block/textobject.go @@ -7,7 +7,7 @@ import ( "github.com/anyproto/anytype-heart/core/block/import/notion/api" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" - dateUtil "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" textUtil "github.com/anyproto/anytype-heart/util/text" ) @@ -239,7 +239,7 @@ func (t *TextObject) handleDateMention(rt api.RichText, if rt.Mention.Date.End != "" { textDate = rt.Mention.Date.End } - date, err := dateUtil.ParseDateId(textDate) + date, err := dateutil.ParseDateId(textDate) if err != nil { return nil } @@ -252,7 +252,7 @@ func (t *TextObject) handleDateMention(rt api.RichText, To: int32(to), }, Type: model.BlockContentTextMark_Mention, - Param: dateUtil.TimeToDateId(date), + Param: dateutil.TimeToDateId(date), }, } } diff --git a/core/block/object/objectcreator/creator.go b/core/block/object/objectcreator/creator.go index 918ce6f01..58744f7f5 100644 --- a/core/block/object/objectcreator/creator.go +++ b/core/block/object/objectcreator/creator.go @@ -21,7 +21,7 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/pb/model" "github.com/anyproto/anytype-heart/space" "github.com/anyproto/anytype-heart/space/clientspace" - "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/internalflag" "github.com/anyproto/anytype-heart/util/pbtypes" ) @@ -185,7 +185,7 @@ func (s *service) createObjectFromTemplate( // buildDateObject does not create real date object. It just builds date object details func buildDateObject(space clientspace.Space, details *types.Struct) (string, *types.Struct, error) { name := pbtypes.GetString(details, bundle.RelationKeyName.String()) - id, err := date.DateNameToId(name) + id, err := dateutil.DateNameToId(name) if err != nil { return "", nil, fmt.Errorf("failed to build date object, as its name is invalid: %w", err) } diff --git a/core/block/object/objectcreator/creator_test.go b/core/block/object/objectcreator/creator_test.go index 3a9213bea..ea8284b79 100644 --- a/core/block/object/objectcreator/creator_test.go +++ b/core/block/object/objectcreator/creator_test.go @@ -16,7 +16,7 @@ import ( "github.com/anyproto/anytype-heart/space/clientspace" "github.com/anyproto/anytype-heart/space/clientspace/mock_clientspace" "github.com/anyproto/anytype-heart/space/mock_space" - "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/pbtypes" ) @@ -112,7 +112,7 @@ func TestService_CreateObject(t *testing.T) { f.spaceService.EXPECT().Get(mock.Anything, mock.Anything).Return(f.spc, nil) f.spc.EXPECT().Id().Return(spaceId) ts := time.Now() - name := date.TimeToDateName(ts) + name := dateutil.TimeToDateName(ts) // when id, details, err := f.service.CreateObject(context.Background(), spaceId, CreateObjectRequest{ @@ -124,7 +124,7 @@ func TestService_CreateObject(t *testing.T) { // then assert.NoError(t, err) - assert.Equal(t, date.TimeToDateId(ts), id) + assert.Equal(t, dateutil.TimeToDateId(ts), id) assert.Equal(t, spaceId, pbtypes.GetString(details, bundle.RelationKeySpaceId.String())) }) diff --git a/core/block/object/objectlink/dependent_objects.go b/core/block/object/objectlink/dependent_objects.go index 7c011e17d..3e3d0dcec 100644 --- a/core/block/object/objectlink/dependent_objects.go +++ b/core/block/object/objectlink/dependent_objects.go @@ -15,7 +15,7 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/bundle" "github.com/anyproto/anytype-heart/pkg/lib/logging" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" - "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/pbtypes" ) @@ -152,7 +152,7 @@ func collectIdsFromDetail(rel *model.RelationLink, det *types.Struct, flags Flag if relInt > 0 { t := time.Unix(relInt, 0) t = t.In(time.Local) - ids = append(ids, date.TimeToDateId(t)) + ids = append(ids, dateutil.TimeToDateId(t)) } return } diff --git a/core/block/source/date.go b/core/block/source/date.go index 0af2714f5..28a7cce07 100644 --- a/core/block/source/date.go +++ b/core/block/source/date.go @@ -15,7 +15,7 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock" "github.com/anyproto/anytype-heart/pkg/lib/localstore/addr" "github.com/anyproto/anytype-heart/pkg/lib/pb/model" - dateutil "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" "github.com/anyproto/anytype-heart/util/pbtypes" ) diff --git a/core/date/suggest.go b/core/date/suggest.go index fef244b36..65fe55f0c 100644 --- a/core/date/suggest.go +++ b/core/date/suggest.go @@ -17,7 +17,7 @@ import ( "github.com/anyproto/anytype-heart/pkg/lib/database" "github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore" "github.com/anyproto/anytype-heart/space" - dateutil "github.com/anyproto/anytype-heart/util/date" + "github.com/anyproto/anytype-heart/util/dateutil" ) func EnrichRecordsWithDateSuggestion( diff --git a/util/date/util.go b/util/dateutil/util.go similarity index 97% rename from util/date/util.go rename to util/dateutil/util.go index 139240b1f..9e6eaada7 100644 --- a/util/date/util.go +++ b/util/dateutil/util.go @@ -1,4 +1,4 @@ -package date +package dateutil import ( "strings"