···9393var schema = []string{
9494 `CREATE TABLE IF NOT EXISTS users (
9595 did TEXT PRIMARY KEY,
9696- handle TEXT NOT NULL,
9797- display_name TEXT,
9898- avatar_url TEXT,
9996 indexed_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
10097 updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
10198 )`,
···274271 `CREATE INDEX IF NOT EXISTS idx_follow_distances_b ON follow_distances(user_b)`,
275272 `CREATE INDEX IF NOT EXISTS idx_follow_distances_a_dist ON follow_distances(user_a, distance)`,
276273 `CREATE INDEX IF NOT EXISTS idx_follows_followed_at ON follows(followed_at)`,
277277- `CREATE INDEX IF NOT EXISTS idx_users_handle ON users(handle)`,
278274 `CREATE VIRTUAL TABLE IF NOT EXISTS articles_fts USING fts5(title, summary, content, author, content=articles, content_rowid=id)`,
279275 `CREATE TRIGGER IF NOT EXISTS articles_ai AFTER INSERT ON articles BEGIN
280276 INSERT INTO articles_fts(rowid, title, summary, content, author) VALUES (new.id, new.title, new.summary, new.content, new.author);
···125125var usersSchema = []string{
126126 `CREATE TABLE IF NOT EXISTS users (
127127 did TEXT PRIMARY KEY,
128128- handle TEXT NOT NULL,
129129- display_name TEXT,
130130- avatar_url TEXT,
131128 indexed_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
132129 updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
133130 )`,
···157154 `CREATE INDEX IF NOT EXISTS idx_follows_target ON follows(target_did)`,
158155 `CREATE INDEX IF NOT EXISTS idx_follows_uri ON follows(uri)`,
159156 `CREATE INDEX IF NOT EXISTS idx_follows_followed_at ON follows(followed_at)`,
160160- `CREATE INDEX IF NOT EXISTS idx_users_handle ON users(handle)`,
161157}
162158163159var articlesSchema = []string{
+4-6
internal/db/social.go
···4242func (s *ArticleStore) GetAnnotation(ctx context.Context, id int64) (*Annotation, error) {
4343 a := &Annotation{}
4444 err := s.db.QueryRowContext(ctx, `
4545- SELECT a.id, a.uri, a.author_did, COALESCE(u.handle, ''), a.feed_url, a.article_url, ar.id, a.quote, a.note, a.tags, a.rating, a.created_at, a.cid
4545+ SELECT a.id, a.uri, a.author_did, a.feed_url, a.article_url, ar.id, a.quote, a.note, a.tags, a.rating, a.created_at, a.cid
4646 FROM articles.annotations a
4747- LEFT JOIN users u ON a.author_did = u.did
4847 LEFT JOIN articles.articles ar ON ar.url = a.article_url AND ar.feed_url = a.feed_url
4948 WHERE a.id = ?
5050- `, id).Scan(&a.ID, &a.URI, &a.AuthorDID, &a.AuthorHandle, &a.FeedURL, &a.ArticleURL, &a.ArticleID,
4949+ `, id).Scan(&a.ID, &a.URI, &a.AuthorDID, &a.FeedURL, &a.ArticleURL, &a.ArticleID,
5150 &a.Quote, &a.Note, &a.Tags, &a.Rating, &a.CreatedAt, &a.CID)
5251 if err != nil {
5352 return nil, err
···8988 args = append(args, authorDID)
9089 }
91909292- query := `SELECT a.id, a.uri, a.author_did, COALESCE(u.handle, ''), a.feed_url, a.article_url, ar.id, a.quote, a.note, a.tags, a.rating, a.created_at, a.cid
9191+ query := `SELECT a.id, a.uri, a.author_did, a.feed_url, a.article_url, ar.id, a.quote, a.note, a.tags, a.rating, a.created_at, a.cid
9392 FROM articles.annotations a
9494- LEFT JOIN users u ON a.author_did = u.did
9593 LEFT JOIN articles.articles ar ON ar.url = a.article_url AND ar.feed_url = a.feed_url`
9694 if len(conds) > 0 {
9795 query += ` WHERE ` + strings.Join(conds, " AND ")
···108106 var annotations []*Annotation
109107 for rows.Next() {
110108 a := &Annotation{}
111111- if err := rows.Scan(&a.ID, &a.URI, &a.AuthorDID, &a.AuthorHandle, &a.FeedURL, &a.ArticleURL, &a.ArticleID,
109109+ if err := rows.Scan(&a.ID, &a.URI, &a.AuthorDID, &a.FeedURL, &a.ArticleURL, &a.ArticleID,
112110 &a.Quote, &a.Note, &a.Tags, &a.Rating, &a.CreatedAt, &a.CID); err != nil {
113111 return nil, err
114112 }