Skip to content

Commit

Permalink
GO-4147: Rename to spaceindex
Browse files Browse the repository at this point in the history
  • Loading branch information
deff7 committed Oct 1, 2024
1 parent 3527d52 commit 9acdab3
Show file tree
Hide file tree
Showing 106 changed files with 275 additions and 275 deletions.
2 changes: 1 addition & 1 deletion core/anytype/account/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *service) ProfileInfo() (Profile, error) {
AccountId: s.AccountID(),
}

profileDetails, err := s.objectStore.SpaceStore(s.personalSpaceId).GetDetails(profile.Id)
profileDetails, err := s.objectStore.SpaceIndex(s.personalSpaceId).GetDetails(profile.Id)
if err != nil {
return profile, err
}
Expand Down
14 changes: 7 additions & 7 deletions core/block/backlinks/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/logging"
"github.com/anyproto/anytype-heart/space"
"github.com/anyproto/anytype-heart/util/pbtypes"
Expand All @@ -31,7 +31,7 @@ const CName = "backlinks-update-watcher"
var log = logging.Logger(CName)

type backlinksUpdater interface {
SubscribeLinksUpdate(callback func(info spaceobjects.LinksUpdateInfo))
SubscribeLinksUpdate(callback func(info spaceindex.LinksUpdateInfo))
}

type backLinksUpdate struct {
Expand Down Expand Up @@ -76,7 +76,7 @@ func (uw *UpdateWatcher) Close(context.Context) error {
}

func (uw *UpdateWatcher) Run(context.Context) error {
uw.updater.SubscribeLinksUpdate(func(info spaceobjects.LinksUpdateInfo) {
uw.updater.SubscribeLinksUpdate(func(info spaceindex.LinksUpdateInfo) {
if err := uw.infoBatch.Add(info); err != nil {
log.With("objectId", info.LinksFromId).Errorf("failed to add backlinks update info to message batch: %v", err)
}
Expand All @@ -86,7 +86,7 @@ func (uw *UpdateWatcher) Run(context.Context) error {
return nil
}

func applyUpdates(m map[string]*backLinksUpdate, update spaceobjects.LinksUpdateInfo) {
func applyUpdates(m map[string]*backLinksUpdate, update spaceindex.LinksUpdateInfo) {
if update.LinksFromId == "" {
return
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func (uw *UpdateWatcher) backlinksUpdateHandler() {

l.Lock()
for _, msg := range msgs {
info, ok := msg.(spaceobjects.LinksUpdateInfo)
info, ok := msg.(spaceindex.LinksUpdateInfo)
if !ok || hasSelfLinks(info) {
continue
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func (uw *UpdateWatcher) updateBackLinksInObject(id string, backlinksUpdate *bac
}

err = spc.DoLockedIfNotExists(id, func() error {
return uw.store.SpaceStore(spaceId).ModifyObjectDetails(id, func(details *types.Struct) (*types.Struct, bool, error) {
return uw.store.SpaceIndex(spaceId).ModifyObjectDetails(id, func(details *types.Struct) (*types.Struct, bool, error) {
return updateBacklinks(details, backlinksUpdate)
})
})
Expand All @@ -233,7 +233,7 @@ func (uw *UpdateWatcher) updateBackLinksInObject(id string, backlinksUpdate *bac

}

func hasSelfLinks(info spaceobjects.LinksUpdateInfo) bool {
func hasSelfLinks(info spaceindex.LinksUpdateInfo) bool {
for _, link := range info.Added {
if link == info.LinksFromId {
return true
Expand Down
2 changes: 1 addition & 1 deletion core/block/bookmark/bookmark_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *service) CreateBookmarkObject(
}
url := pbtypes.GetString(details, bundle.RelationKeySource.String())

records, err := s.store.SpaceStore(spaceID).Query(database.Query{
records, err := s.store.SpaceIndex(spaceID).Query(database.Query{
Sorts: []*model.BlockContentDataviewSort{
{
RelationKey: bundle.RelationKeyLastModifiedDate.String(),
Expand Down
2 changes: 1 addition & 1 deletion core/block/collection/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (s *Service) setDefaultObjectTypeToViews(spaceId string, st *state.State) {
}

func (s *Service) isNotCreatableType(spaceId string, id string) bool {
uk, err := s.objectStore.SpaceStore(spaceId).GetUniqueKeyById(id)
uk, err := s.objectStore.SpaceIndex(spaceId).GetUniqueKeyById(id)
if err != nil {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion core/block/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type debugObject struct {

func (s *Service) debugListObjectsPerSpace(req *http.Request) ([]debugObject, error) {
spaceId := chi.URLParam(req, "spaceId")
ids, _, err := s.objectStore.SpaceStore(spaceId).QueryObjectIDs(database.Query{
ids, _, err := s.objectStore.SpaceIndex(spaceId).QueryObjectIDs(database.Query{
Filters: nil,
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/block/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *Service) deleteDerivedObject(id domain.FullID, spc clientspace.Space) (
}

func (s *Service) deleteRelationOptions(spaceId string, relationKey string) error {
relationOptions, _, err := s.objectStore.SpaceStore(spaceId).QueryObjectIDs(database.Query{
relationOptions, _, err := s.objectStore.SpaceIndex(spaceId).QueryObjectIDs(database.Query{
Filters: []*model.BlockContentDataviewFilter{
{
RelationKey: bundle.RelationKeyLayout.String(),
Expand Down Expand Up @@ -144,7 +144,7 @@ func (s *Service) OnDelete(id domain.FullID, workspaceRemove func() error) error
if err != nil {
log.With("error", err, "objectId", id.ObjectID).Error("failed to perform delete operation on object")
}
if err := s.objectStore.SpaceStore(id.SpaceID).DeleteObject(id.ObjectID); err != nil {
if err := s.objectStore.SpaceIndex(id.SpaceID).DeleteObject(id.ObjectID); err != nil {
return fmt.Errorf("delete object from local store: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion core/block/detailservice/relations.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *service) ListRelationsWithValue(spaceId string, value *types.Value) (ke
countersByKeys := make(map[string]int64)
detailHandlesValue := generateFilter(value)

err = s.store.SpaceStore(spaceId).QueryIterate(database.Query{Filters: nil}, func(details *types.Struct) {
err = s.store.SpaceIndex(spaceId).QueryIterate(database.Query{Filters: nil}, func(details *types.Struct) {
for key, valueToCheck := range details.Fields {
if detailHandlesValue(valueToCheck) {
if counter, ok := countersByKeys[key]; ok {
Expand Down
20 changes: 10 additions & 10 deletions core/block/detailservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestService_SetWorkspaceDashboardId(t *testing.T) {
assert.Equal(t, wsObjectId, objectId)
ws := &editor.Workspaces{
SmartBlock: sb,
AllOperations: basic.NewBasic(sb, fx.store.SpaceStore(spaceId), nil, nil, nil),
AllOperations: basic.NewBasic(sb, fx.store.SpaceIndex(spaceId), nil, nil, nil),
}
return ws, nil
})
Expand All @@ -299,7 +299,7 @@ func TestService_SetWorkspaceDashboardId(t *testing.T) {
assert.Equal(t, wsObjectId, objectId)
ws := &editor.Workspaces{
SmartBlock: sb,
AllOperations: basic.NewBasic(sb, fx.store.SpaceStore(spaceId), nil, nil, nil),
AllOperations: basic.NewBasic(sb, fx.store.SpaceIndex(spaceId), nil, nil, nil),
}
return ws, nil
})
Expand Down Expand Up @@ -332,7 +332,7 @@ func TestService_SetListIsFavorite(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Home: homeId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
require.Equal(t, homeId, objectId)
return editor.NewDashboard(sb, fx.store.SpaceStore(spaceId), nil), nil
return editor.NewDashboard(sb, fx.store.SpaceIndex(spaceId), nil), nil
})

// when
Expand All @@ -355,7 +355,7 @@ func TestService_SetListIsFavorite(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Home: homeId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
require.Equal(t, homeId, objectId)
return editor.NewDashboard(sb, fx.store.SpaceStore(spaceId), nil), nil
return editor.NewDashboard(sb, fx.store.SpaceIndex(spaceId), nil), nil
})

// when
Expand All @@ -380,7 +380,7 @@ func TestService_SetListIsFavorite(t *testing.T) {
return nil, fmt.Errorf("unexpected error")
}
flag = true
return editor.NewDashboard(sb, fx.store.SpaceStore(spaceId), nil), nil
return editor.NewDashboard(sb, fx.store.SpaceIndex(spaceId), nil), nil
})

// when
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestService_SetIsArchived(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Archive: binId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
if objectId == binId {
return editor.NewArchive(sb, fx.store.SpaceStore(spaceId)), nil
return editor.NewArchive(sb, fx.store.SpaceIndex(spaceId)), nil
}
return smarttest.New(objectId), nil
})
Expand All @@ -448,7 +448,7 @@ func TestService_SetIsArchived(t *testing.T) {
fx.store.AddObjects(t, spaceId, objects)
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
if objectId == binId {
return editor.NewArchive(sb, fx.store.SpaceStore(spaceId)), nil
return editor.NewArchive(sb, fx.store.SpaceIndex(spaceId)), nil
}
return smarttest.New(objectId), nil
})
Expand Down Expand Up @@ -482,7 +482,7 @@ func TestService_SetListIsArchived(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Archive: binId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
if objectId == binId {
return editor.NewArchive(sb, fx.store.SpaceStore(spaceId)), nil
return editor.NewArchive(sb, fx.store.SpaceIndex(spaceId)), nil
}
return smarttest.New(objectId), nil
})
Expand Down Expand Up @@ -510,7 +510,7 @@ func TestService_SetListIsArchived(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Archive: binId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
if objectId == binId {
return editor.NewArchive(sb, fx.store.SpaceStore(spaceId)), nil
return editor.NewArchive(sb, fx.store.SpaceIndex(spaceId)), nil
}
return smarttest.New(objectId), nil
})
Expand All @@ -532,7 +532,7 @@ func TestService_SetListIsArchived(t *testing.T) {
fx.space.EXPECT().DerivedIDs().Return(threads.DerivedSmartblockIds{Archive: binId})
fx.space.EXPECT().GetObject(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, objectId string) (smartblock.SmartBlock, error) {
if objectId == binId {
return editor.NewArchive(sb, fx.store.SpaceStore(spaceId)), nil
return editor.NewArchive(sb, fx.store.SpaceIndex(spaceId)), nil
}
if objectId == "obj2" {
return nil, fmt.Errorf("failed to get object")
Expand Down
4 changes: 2 additions & 2 deletions core/block/detailservice/set_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *service) SetListIsFavorite(objectIds []string, isFavorite bool) error {
resultError error
)
for spaceId, objectIds := range objectIdsPerSpace {
ids, err := s.store.SpaceStore(spaceId).HasIDs(objectIds)
ids, err := s.store.SpaceIndex(spaceId).HasIDs(objectIds)
if err != nil {
return err
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func (s *service) setIsArchivedForObjects(spaceId string, objectIds []string, is
return fmt.Errorf("unexpected archive block type: %T", b)
}

ids, err := s.store.SpaceStore(spaceId).HasIDs(objectIds)
ids, err := s.store.SpaceIndex(spaceId).HasIDs(objectIds)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions core/block/editor/accountobject/accountobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/anyproto/anytype-heart/core/session"
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
)
Expand Down Expand Up @@ -69,8 +69,8 @@ var _ AccountObject = (*accountObject)(nil)

type accountObject struct {
smartblock.SmartBlock
spaceObjects spaceobjects.Store
bs basic.DetailsSettable
spaceObjects spaceindex.Store
bs basic.DetailsSettable
profileSubscription ProfileSubscription
state *storestate.StoreState
storeSource source.Store
Expand All @@ -91,7 +91,7 @@ func (a *accountObject) SetDetailsAndUpdateLastUsed(ctx session.Context, details

func New(
sb smartblock.SmartBlock,
spaceObjects spaceobjects.Store,
spaceObjects spaceindex.Store,
layoutConverter converter.LayoutConverter,
fileObjectService fileobject.Service,
lastUsedUpdater lastused.ObjectUsageUpdater,
Expand Down
6 changes: 3 additions & 3 deletions core/block/editor/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/anyproto/anytype-heart/core/relationutils"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/database"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
"github.com/anyproto/anytype-heart/util/slice"
Expand All @@ -24,12 +24,12 @@ var archiveRequiredRelations = []domain.RelationKey{}
type Archive struct {
smartblock.SmartBlock
collection.Collection
objectStore spaceobjects.Store
objectStore spaceindex.Store
}

func NewArchive(
sb smartblock.SmartBlock,
objectStore spaceobjects.Store,
objectStore spaceindex.Store,
) *Archive {
return &Archive{
SmartBlock: sb,
Expand Down
4 changes: 2 additions & 2 deletions core/block/editor/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"github.com/anyproto/anytype-heart/core/block/editor/smartblock"
"github.com/anyproto/anytype-heart/core/block/editor/smartblock/smarttest"
"github.com/anyproto/anytype-heart/core/block/migration"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
)

func NewArchiveTest(t *testing.T) (*Archive, error) {
sb := smarttest.New("root")
objectStore := spaceobjects.NewStoreFixture(t)
objectStore := spaceindex.NewStoreFixture(t)
a := &Archive{
SmartBlock: sb,
Collection: collection.NewCollection(sb, objectStore),
Expand Down
8 changes: 4 additions & 4 deletions core/block/editor/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/anyproto/anytype-heart/core/session"
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
"github.com/anyproto/anytype-heart/util/slice"
Expand Down Expand Up @@ -104,7 +104,7 @@ type Updatable interface {

func NewBasic(
sb smartblock.SmartBlock,
objectStore spaceobjects.Store,
objectStore spaceindex.Store,
layoutConverter converter.LayoutConverter,
fileObjectService fileobject.Service,
lastUsedUpdater lastused.ObjectUsageUpdater,
Expand All @@ -121,8 +121,8 @@ func NewBasic(
type basic struct {
smartblock.SmartBlock

objectStore spaceobjects.Store
layoutConverter converter.LayoutConverter
objectStore spaceindex.Store
layoutConverter converter.LayoutConverter
fileObjectService fileobject.Service
lastUsedUpdater lastused.ObjectUsageUpdater
}
Expand Down
6 changes: 3 additions & 3 deletions core/block/editor/basic/details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"github.com/anyproto/anytype-heart/core/block/editor/smartblock/smarttest"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
)

type duFixture struct {
sb *smarttest.SmartTest
store *spaceobjects.StoreFixture
store *spaceindex.StoreFixture
basic DetailsUpdatable
}

Expand All @@ -31,7 +31,7 @@ func newDUFixture(t *testing.T) *duFixture {
sb.SetDetails(nil, nil, false)
sb.SetSpaceId(spaceId)

store := spaceobjects.NewStoreFixture(t)
store := spaceindex.NewStoreFixture(t)

b := NewBasic(sb, store, converter.NewLayoutConverter(), nil, nil)

Expand Down
8 changes: 4 additions & 4 deletions core/block/editor/basic/extract_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
coresb "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceobjects"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore/spaceindex"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
"github.com/anyproto/anytype-heart/util/pbtypes"
"github.com/anyproto/anytype-heart/util/slice"
Expand Down Expand Up @@ -613,13 +613,13 @@ func generateState(root string, blocks []simple.Block) *state.State {

type fixture struct {
t *testing.T
store *spaceobjects.StoreFixture
store *spaceindex.StoreFixture
}

func newFixture(t *testing.T) *fixture {
objectStore := spaceobjects.NewStoreFixture(t)
objectStore := spaceindex.NewStoreFixture(t)

objectStore.AddObjects(t, []spaceobjects.TestObject{
objectStore.AddObjects(t, []spaceindex.TestObject{
{
bundle.RelationKeyId: pbtypes.String("id1"),
bundle.RelationKeyUniqueKey: pbtypes.String("ot-note"),
Expand Down
Loading

0 comments on commit 9acdab3

Please sign in to comment.