-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(worker/mastodon): apply Postgres DB for mastodon handle storage …
…and modify query functions (#578) Co-authored-by: brucexc <[email protected]>
- Loading branch information
1 parent
60689f8
commit 47c389c
Showing
10 changed files
with
201 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
internal/database/dialer/postgres/migration/20240922233919_add_mastodon_handles.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
-- +goose Up | ||
CREATE TABLE IF NOT EXISTS dataset_mastodon_handles ( | ||
handle VARCHAR(255) PRIMARY KEY, | ||
last_updated TIMESTAMP NOT NULL | ||
-- +goose StatementBegin | ||
CREATE TABLE IF NOT EXISTS dataset_mastodon_update_handles ( | ||
"handle" text PRIMARY KEY, | ||
"created_at" timestamptz NOT NULL DEFAULT now(), | ||
"updated_at" timestamptz NOT NULL DEFAULT now() | ||
); | ||
|
||
CREATE INDEX idx_mastodon_handles_last_updated ON dataset_mastodon_handles(last_updated); | ||
CREATE INDEX idx_mastodon_update_handles_time_at ON dataset_mastodon_update_handles(updated_at DESC,created_at DESC); | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
DROP TABLE IF EXISTS dataset_mastodon_handles; | ||
-- +goose StatementEnd | ||
DROP TABLE IF EXISTS dataset_mastodon_update_handles; | ||
-- +goose StatementEnd |
30 changes: 0 additions & 30 deletions
30
internal/database/dialer/postgres/table/dataset_mastodon_handle.go
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
internal/database/dialer/postgres/table/dataset_mastodon_update_handle.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package table | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/rss3-network/node/internal/database/model" | ||
) | ||
|
||
var _ model.MastodonHandleTransformer = (*DatasetMastodonUpdateHandle)(nil) | ||
|
||
type DatasetMastodonUpdateHandle struct { | ||
Handle string `gorm:"column:handle;primaryKey"` | ||
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"` | ||
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"` | ||
} | ||
|
||
func (d *DatasetMastodonUpdateHandle) Import(handle *model.MastodonHandle) error { | ||
d.Handle = handle.Handle | ||
d.UpdatedAt = handle.UpdatedAt | ||
d.CreatedAt = handle.CreatedAt | ||
|
||
return nil | ||
} | ||
|
||
func (d *DatasetMastodonUpdateHandle) Export() (*model.MastodonHandle, error) { | ||
handle := model.MastodonHandle{ | ||
Handle: d.Handle, | ||
UpdatedAt: d.UpdatedAt, | ||
CreatedAt: d.CreatedAt, | ||
} | ||
|
||
return &handle, nil | ||
} | ||
|
||
func (DatasetMastodonUpdateHandle) TableName() string { | ||
return "dataset_mastodon_update_handles" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.