added thread list to get accounts endpoint

This commit is contained in:
overflowerror 2021-08-15 21:07:27 +02:00
parent 9fd80d4575
commit a4b45119cd
5 changed files with 23 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
func (d *Data) GetAccountsByUser(user *models.User) ([]models.Account, error) {
var accounts []models.Account
err := d.db.
Preload("Threads").
Where("user_id = ?", user.ID).
Find(&accounts).
Error

View file

@ -7,6 +7,8 @@ type Account struct {
UserID uuid.UUID `json:"-"`
User *User `json:"-"`
Threads []Thread `json:"threads"`
ScreenName string `json:"screen_name"`
Name string `json:"name"`
TwitterID *int64 `json:"twitter_id"`

View file

@ -1,3 +1,4 @@
import Thread from "./Thread";
type Account = {
id: string
@ -5,6 +6,7 @@ type Account = {
screen_name: string
twitter_id: string
avatar_url: string
threads: Thread[]
}
export default Account

View file

@ -0,0 +1,17 @@
export enum ThreadStatus {
SCHEDULED = "SCHEDULED",
PROCESSING = "PROCESSING",
FAILED = "FAILED",
DONE = "DONE",
}
type Thread = {
id: string,
//tweets: Tweet[],
scheduled_for: Date,
status: ThreadStatus,
error: string|null
}
export default Thread

View file

@ -29,6 +29,7 @@ const Dashboard: FunctionComponent<DashboardProps> = () => {
useEffect(() => {
accountEndpoint.getAll()
.then(accounts => {
console.dir(accounts)
setAccounts(accounts)
setLoading(false)
})