-
Notifications
You must be signed in to change notification settings - Fork 73
GO-4792: make csv export for anytype #2170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GO-4792: make csv export for anytype #2170
Conversation
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Coverage provided by https://github.com/seriousben/go-patch-cover-action |
core/block/export/export.go
Outdated
if info.Id == addr.AnytypeProfileId { | ||
return false | ||
} | ||
if !isProtobuf && (!validTypeForNonProtobuf(sbType) || !validLayoutForNonProtobuf(info.Details)) { | ||
if !shouldExportRelationsAndType && !validTypeForNonProtobuf(sbType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validTypeForNonProtobuf
could be renamed to validDocumentType
according to export naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -47,11 +43,11 @@ func (d *dot) Add(space smartblock.Space, st *state.State) error { | |||
return nil | |||
} | |||
|
|||
func (d *dot) Convert(sbType model.SmartBlockType) []byte { | |||
func (d *dot) Convert(st *state.State, sbType model.SmartBlockType, filename string) []byte { | |||
panic("not supported on windows") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is not supported on mobiles as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
return str | ||
} | ||
|
||
func getStringValueFromDetail(details *domain.Details, key domain.RelationKey) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also support int lists, e.g. restrictions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
"github.com/anyproto/anytype-heart/pkg/lib/pb/model" | ||
) | ||
|
||
func ExtractHeaders(spaceIndex spaceindex.Store, keys []string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok for this function, if len(keys) != len(records)
?
We do not return error in current implementtion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
core/converter/md/csv/converter.go
Outdated
return headersKeys, headersName, nil | ||
} | ||
|
||
func findDataviewBlock(st *state.State) *model.Block { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could return the very *model.BlockContentDtaview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
core/converter/md/csv/converter.go
Outdated
|
||
func (c *Converter) extractHeaders(dataview *model.BlockContentDataview, spaceId string) ([]string, []string, error) { | ||
var headersKeys []string | ||
for _, relation := range dataview.Views[0].Relations { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we look into relations of first view?
It seems to be a product question, but we have some data inside dtaview block to calculate good view candidate for export. E.g. activeView field carries id of last active view within current session. view.Type handles type of view. Grid and List fit to CSV export, while Calendar or Graph not so much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is product questions, I suppose
core/converter/md/md.go
Outdated
func NewMDConverter(s *state.State, fn FileNamer) converter.Converter { | ||
return &MD{s: s, fn: fn} | ||
func NewMDConverter(fn FileNamer, store objectstore.ObjectStore, knownDocs map[string]*domain.Details) converter.Converter { | ||
return &MD{fn: fn, objectTypeFiles: csv.ObjectTypeFiles{}, store: store, listCsv: csv.NewConverter(store, knownDocs), knownDocs: knownDocs} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it is better to initialize new struct vertically
return &MD{
fn: fn,
objectTypeFiles: csv.ObjectTypeFiles{},
store: store,
listCsv: csv.NewConverter(store, knownDocs),
knownDocs: knownDocs,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
Signed-off-by: AnastasiaShemyakinskaya <[email protected]>
|
Object types csv contain links to markdown files with objects.
Collections and sets are converted to csv files with table, based on the first dataview view and visible relations. If object from collection is presented in result export, the row with object details is added to result table.