Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
0c673d49
Commit
0c673d49
authored
May 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: retire memo tags
parent
d3744ccf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
53 deletions
+9
-53
memo_service.go
server/router/api/v1/memo_service.go
+0
-1
memo.go
store/db/mysql/memo.go
+2
-16
memo.go
store/db/postgres/memo.go
+3
-17
memo.go
store/db/sqlite/memo.go
+4
-18
memo.go
store/memo.go
+0
-1
No files found.
server/router/api/v1/memo_service.go
View file @
0c673d49
...
@@ -780,7 +780,6 @@ func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
...
@@ -780,7 +780,6 @@ func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
Content
:
memo
.
Content
,
Content
:
memo
.
Content
,
Nodes
:
convertFromASTNodes
(
nodes
),
Nodes
:
convertFromASTNodes
(
nodes
),
Visibility
:
convertVisibilityFromStore
(
memo
.
Visibility
),
Visibility
:
convertVisibilityFromStore
(
memo
.
Visibility
),
Tags
:
memo
.
Tags
,
Pinned
:
memo
.
Pinned
,
Pinned
:
memo
.
Pinned
,
ParentId
:
memo
.
ParentID
,
ParentId
:
memo
.
ParentID
,
Relations
:
listMemoRelationsResponse
.
Relations
,
Relations
:
listMemoRelationsResponse
.
Relations
,
...
...
store/db/mysql/memo.go
View file @
0c673d49
...
@@ -2,7 +2,6 @@ package mysql
...
@@ -2,7 +2,6 @@ package mysql
import
(
import
(
"context"
"context"
"encoding/json"
"fmt"
"fmt"
"strings"
"strings"
...
@@ -16,14 +15,6 @@ import (
...
@@ -16,14 +15,6 @@ import (
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
fields
:=
[]
string
{
"`uid`"
,
"`creator_id`"
,
"`content`"
,
"`visibility`"
,
"`tags`"
,
"`payload`"
}
fields
:=
[]
string
{
"`uid`"
,
"`creator_id`"
,
"`content`"
,
"`visibility`"
,
"`tags`"
,
"`payload`"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
tags
:=
"[]"
if
len
(
create
.
Tags
)
!=
0
{
tagsBytes
,
err
:=
json
.
Marshal
(
create
.
Tags
)
if
err
!=
nil
{
return
nil
,
err
}
tags
=
string
(
tagsBytes
)
}
payload
:=
"{}"
payload
:=
"{}"
if
create
.
Payload
!=
nil
{
if
create
.
Payload
!=
nil
{
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
...
@@ -32,7 +23,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -32,7 +23,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
}
}
payload
=
string
(
payloadBytes
)
payload
=
string
(
payloadBytes
)
}
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
tags
,
payload
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
"[]"
,
payload
}
stmt
:=
"INSERT INTO `memo` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
")"
stmt
:=
"INSERT INTO `memo` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
")"
result
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
args
...
)
result
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
args
...
)
...
@@ -129,7 +120,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -129,7 +120,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
"UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`"
,
"UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`"
,
"`memo`.`row_status` AS `row_status`"
,
"`memo`.`row_status` AS `row_status`"
,
"`memo`.`visibility` AS `visibility`"
,
"`memo`.`visibility` AS `visibility`"
,
"`memo`.`tags` AS `tags`"
,
"`memo`.`payload` AS `payload`"
,
"`memo`.`payload` AS `payload`"
,
"IFNULL(`memo_organizer`.`pinned`, 0) AS `pinned`"
,
"IFNULL(`memo_organizer`.`pinned`, 0) AS `pinned`"
,
"`memo_relation`.`related_memo_id` AS `parent_id`"
,
"`memo_relation`.`related_memo_id` AS `parent_id`"
,
...
@@ -155,7 +145,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -155,7 +145,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
list
:=
make
([]
*
store
.
Memo
,
0
)
list
:=
make
([]
*
store
.
Memo
,
0
)
for
rows
.
Next
()
{
for
rows
.
Next
()
{
var
memo
store
.
Memo
var
memo
store
.
Memo
var
tagsBytes
,
payloadBytes
[]
byte
var
payloadBytes
[]
byte
dests
:=
[]
any
{
dests
:=
[]
any
{
&
memo
.
ID
,
&
memo
.
ID
,
&
memo
.
UID
,
&
memo
.
UID
,
...
@@ -164,7 +154,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -164,7 +154,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
&
memo
.
UpdatedTs
,
&
memo
.
UpdatedTs
,
&
memo
.
RowStatus
,
&
memo
.
RowStatus
,
&
memo
.
Visibility
,
&
memo
.
Visibility
,
&
tagsBytes
,
&
payloadBytes
,
&
payloadBytes
,
&
memo
.
Pinned
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memo
.
ParentID
,
...
@@ -175,9 +164,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -175,9 +164,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
json
.
Unmarshal
(
tagsBytes
,
&
memo
.
Tags
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal tags"
)
}
payload
:=
&
storepb
.
MemoPayload
{}
payload
:=
&
storepb
.
MemoPayload
{}
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
...
...
store/db/postgres/memo.go
View file @
0c673d49
...
@@ -2,7 +2,6 @@ package postgres
...
@@ -2,7 +2,6 @@ package postgres
import
(
import
(
"context"
"context"
"encoding/json"
"fmt"
"fmt"
"strings"
"strings"
...
@@ -14,15 +13,7 @@ import (
...
@@ -14,15 +13,7 @@ import (
)
)
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
fields
:=
[]
string
{
"uid"
,
"creator_id"
,
"content"
,
"visibility"
,
"tags"
,
"payload"
}
fields
:=
[]
string
{
"uid"
,
"creator_id"
,
"content"
,
"visibility"
,
"payload"
}
tags
:=
"[]"
if
len
(
create
.
Tags
)
!=
0
{
tagsBytes
,
err
:=
json
.
Marshal
(
create
.
Tags
)
if
err
!=
nil
{
return
nil
,
err
}
tags
=
string
(
tagsBytes
)
}
payload
:=
"{}"
payload
:=
"{}"
if
create
.
Payload
!=
nil
{
if
create
.
Payload
!=
nil
{
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
...
@@ -31,7 +22,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -31,7 +22,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
}
}
payload
=
string
(
payloadBytes
)
payload
=
string
(
payloadBytes
)
}
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
tags
,
payload
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
payload
}
stmt
:=
"INSERT INTO memo ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
placeholders
(
len
(
args
))
+
") RETURNING id, created_ts, updated_ts, row_status"
stmt
:=
"INSERT INTO memo ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
placeholders
(
len
(
args
))
+
") RETURNING id, created_ts, updated_ts, row_status"
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
...
@@ -120,7 +111,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -120,7 +111,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
`memo.updated_ts AS updated_ts`
,
`memo.updated_ts AS updated_ts`
,
`memo.row_status AS row_status`
,
`memo.row_status AS row_status`
,
`memo.visibility AS visibility`
,
`memo.visibility AS visibility`
,
`memo.tags AS tags`
,
`memo.payload AS payload`
,
`memo.payload AS payload`
,
`COALESCE(memo_organizer.pinned, 0) AS pinned`
,
`COALESCE(memo_organizer.pinned, 0) AS pinned`
,
`memo_relation.related_memo_id AS parent_id`
,
`memo_relation.related_memo_id AS parent_id`
,
...
@@ -151,7 +141,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -151,7 +141,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
list
:=
make
([]
*
store
.
Memo
,
0
)
list
:=
make
([]
*
store
.
Memo
,
0
)
for
rows
.
Next
()
{
for
rows
.
Next
()
{
var
memo
store
.
Memo
var
memo
store
.
Memo
var
tagsBytes
,
payloadBytes
[]
byte
var
payloadBytes
[]
byte
dests
:=
[]
any
{
dests
:=
[]
any
{
&
memo
.
ID
,
&
memo
.
ID
,
&
memo
.
UID
,
&
memo
.
UID
,
...
@@ -160,7 +150,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -160,7 +150,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
&
memo
.
UpdatedTs
,
&
memo
.
UpdatedTs
,
&
memo
.
RowStatus
,
&
memo
.
RowStatus
,
&
memo
.
Visibility
,
&
memo
.
Visibility
,
&
tagsBytes
,
&
payloadBytes
,
&
payloadBytes
,
&
memo
.
Pinned
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memo
.
ParentID
,
...
@@ -171,9 +160,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -171,9 +160,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
json
.
Unmarshal
(
tagsBytes
,
&
memo
.
Tags
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal tags"
)
}
payload
:=
&
storepb
.
MemoPayload
{}
payload
:=
&
storepb
.
MemoPayload
{}
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
...
...
store/db/sqlite/memo.go
View file @
0c673d49
...
@@ -2,7 +2,6 @@ package sqlite
...
@@ -2,7 +2,6 @@ package sqlite
import
(
import
(
"context"
"context"
"encoding/json"
"fmt"
"fmt"
"strings"
"strings"
...
@@ -14,16 +13,8 @@ import (
...
@@ -14,16 +13,8 @@ import (
)
)
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
CreateMemo
(
ctx
context
.
Context
,
create
*
store
.
Memo
)
(
*
store
.
Memo
,
error
)
{
fields
:=
[]
string
{
"`uid`"
,
"`creator_id`"
,
"`content`"
,
"`visibility`"
,
"`tags`"
,
"`payload`"
}
fields
:=
[]
string
{
"`uid`"
,
"`creator_id`"
,
"`content`"
,
"`visibility`"
,
"`payload`"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
tags
:=
"[]"
if
len
(
create
.
Tags
)
!=
0
{
tagsBytes
,
err
:=
json
.
Marshal
(
create
.
Tags
)
if
err
!=
nil
{
return
nil
,
err
}
tags
=
string
(
tagsBytes
)
}
payload
:=
"{}"
payload
:=
"{}"
if
create
.
Payload
!=
nil
{
if
create
.
Payload
!=
nil
{
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
payloadBytes
,
err
:=
protojson
.
Marshal
(
create
.
Payload
)
...
@@ -32,7 +23,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -32,7 +23,7 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
}
}
payload
=
string
(
payloadBytes
)
payload
=
string
(
payloadBytes
)
}
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
tags
,
payload
}
args
:=
[]
any
{
create
.
UID
,
create
.
CreatorID
,
create
.
Content
,
create
.
Visibility
,
payload
}
stmt
:=
"INSERT INTO `memo` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
stmt
:=
"INSERT INTO `memo` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
...
@@ -121,7 +112,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -121,7 +112,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
"`memo`.`updated_ts` AS `updated_ts`"
,
"`memo`.`updated_ts` AS `updated_ts`"
,
"`memo`.`row_status` AS `row_status`"
,
"`memo`.`row_status` AS `row_status`"
,
"`memo`.`visibility` AS `visibility`"
,
"`memo`.`visibility` AS `visibility`"
,
"`memo`.`tags` AS `tags`"
,
"`memo`.`payload` AS `payload`"
,
"`memo`.`payload` AS `payload`"
,
"IFNULL(`memo_organizer`.`pinned`, 0) AS `pinned`"
,
"IFNULL(`memo_organizer`.`pinned`, 0) AS `pinned`"
,
"`memo_relation`.`related_memo_id` AS `parent_id`"
,
"`memo_relation`.`related_memo_id` AS `parent_id`"
,
...
@@ -151,7 +141,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -151,7 +141,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
list
:=
make
([]
*
store
.
Memo
,
0
)
list
:=
make
([]
*
store
.
Memo
,
0
)
for
rows
.
Next
()
{
for
rows
.
Next
()
{
var
memo
store
.
Memo
var
memo
store
.
Memo
var
tagsBytes
,
payloadBytes
[]
byte
var
payloadBytes
[]
byte
dests
:=
[]
any
{
dests
:=
[]
any
{
&
memo
.
ID
,
&
memo
.
ID
,
&
memo
.
UID
,
&
memo
.
UID
,
...
@@ -160,7 +150,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -160,7 +150,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
&
memo
.
UpdatedTs
,
&
memo
.
UpdatedTs
,
&
memo
.
RowStatus
,
&
memo
.
RowStatus
,
&
memo
.
Visibility
,
&
memo
.
Visibility
,
&
tagsBytes
,
&
payloadBytes
,
&
payloadBytes
,
&
memo
.
Pinned
,
&
memo
.
Pinned
,
&
memo
.
ParentID
,
&
memo
.
ParentID
,
...
@@ -171,9 +160,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -171,9 +160,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
json
.
Unmarshal
(
tagsBytes
,
&
memo
.
Tags
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal tags"
)
}
payload
:=
&
storepb
.
MemoPayload
{}
payload
:=
&
storepb
.
MemoPayload
{}
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
if
err
:=
protojsonUnmarshaler
.
Unmarshal
(
payloadBytes
,
payload
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to unmarshal payload"
)
...
...
store/memo.go
View file @
0c673d49
...
@@ -48,7 +48,6 @@ type Memo struct {
...
@@ -48,7 +48,6 @@ type Memo struct {
// Domain specific fields
// Domain specific fields
Content
string
Content
string
Visibility
Visibility
Visibility
Visibility
Tags
[]
string
Payload
*
storepb
.
MemoPayload
Payload
*
storepb
.
MemoPayload
// Composed fields
// Composed fields
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment