-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsource_evidence.go
More file actions
61 lines (57 loc) · 1.64 KB
/
Copy pathsource_evidence.go
File metadata and controls
61 lines (57 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package store
import (
"context"
"database/sql"
"errors"
"fmt"
"github.com/darron/dbrain/internal/model"
)
func (s *Store) GetSourceEvidence(ctx context.Context, lookup string) (model.SourceDocument, error) {
row := s.db.QueryRowContext(ctx, `
SELECT
id, source_key, canonical_url, normalized_url, source_type, domain, title, description, site_name,
extract_status, extracted_at, extract_tool,
summary_text, summary_status, summarized_at, summary_model, summary_tool,
note_path, user_tags, created_at, updated_at
FROM sources
WHERE source_key = ?
OR canonical_url = ?
OR normalized_url = ?
OR note_path = ?
LIMIT 1`, lookup, lookup, lookup, lookup)
var source model.SourceDocument
var extractedAt, summarizedAt, createdAt, updatedAt string
if err := row.Scan(
&source.ID,
&source.SourceKey,
&source.CanonicalURL,
&source.NormalizedURL,
&source.SourceType,
&source.Domain,
&source.Title,
&source.Description,
&source.SiteName,
&source.ExtractStatus,
&extractedAt,
&source.ExtractTool,
&source.SummaryText,
&source.SummaryStatus,
&summarizedAt,
&source.SummaryModel,
&source.SummaryTool,
&source.NotePath,
&source.UserTags,
&createdAt,
&updatedAt,
); err != nil {
if errors.Is(err, sql.ErrNoRows) {
return model.SourceDocument{}, fmt.Errorf("source not found: %s", lookup)
}
return model.SourceDocument{}, fmt.Errorf("load source evidence %s: %w", lookup, err)
}
source.ExtractedAt = parseStoredTime(extractedAt)
source.SummarizedAt = parseStoredTime(summarizedAt)
source.CreatedAt = parseStoredTime(createdAt)
source.UpdatedAt = parseStoredTime(updatedAt)
return source, nil
}