Mostly done, first cut
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"html/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Bookmark struct {
|
||||
ID uint64 `boltholdKey:"ID"`
|
||||
@@ -12,6 +15,10 @@ type Bookmark struct {
|
||||
TimestampLastScraped time.Time
|
||||
}
|
||||
|
||||
func (bm Bookmark) Type() string {
|
||||
return "bookmark"
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
Fetched time.Time
|
||||
Title string
|
||||
@@ -19,3 +26,13 @@ type PageInfo struct {
|
||||
StatusCode int
|
||||
RawText string
|
||||
}
|
||||
|
||||
func (pi PageInfo) Type() string {
|
||||
return "info"
|
||||
}
|
||||
|
||||
type BookmarkSearchResult struct {
|
||||
Bookmark Bookmark
|
||||
Score float64
|
||||
Highlight template.HTML
|
||||
}
|
||||
|
||||
@@ -1,39 +1 @@
|
||||
package entity
|
||||
|
||||
type WordIndex struct {
|
||||
Word string `bolthold:"index"`
|
||||
// Bitmap roaring.Bitmap
|
||||
Bitmap map[uint64]bool
|
||||
}
|
||||
|
||||
// func (wi WordIndex) GobEncode() ([]byte, error) {
|
||||
|
||||
// bmBuf := new(bytes.Buffer)
|
||||
// wi.Bitmap.WriteTo(bmBuf) // we omit error handling
|
||||
|
||||
// wordBytes := []byte(wi.Word)
|
||||
// serialised := make([]byte, 4, 4)
|
||||
// binary.BigEndian.PutUint32(serialised, uint32(len(wordBytes)))
|
||||
|
||||
// serialised = append(serialised, wordBytes...)
|
||||
// serialised = append(serialised, bmBuf.Bytes()...)
|
||||
// // log.Printf("serialised: %v", serialised)
|
||||
|
||||
// // log.Printf("serialised to %d bytes for word %w\n%#v", len(serialised), wi.Word, serialised)
|
||||
|
||||
// return serialised, nil
|
||||
// }
|
||||
|
||||
// func (wi *WordIndex) GobDecode(b []byte) error {
|
||||
// size := binary.BigEndian.Uint32(b[0:4])
|
||||
// wi.Word = string(b[4 : size+4])
|
||||
// // log.Printf("word is %s size was %d\n%v", wi.Word, size, b)
|
||||
|
||||
// bmBuf := bytes.NewReader(b[size+4:])
|
||||
|
||||
// wi.Bitmap = *roaring.New()
|
||||
// _, err := wi.Bitmap.ReadFrom(bmBuf)
|
||||
// // log.Printf("N: %d, err: %s", n, err)
|
||||
|
||||
// return err
|
||||
// }
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
)
|
||||
|
||||
type DBStats struct {
|
||||
History map[time.Time]BookmarkInfo
|
||||
FileSize int
|
||||
Searches int
|
||||
History map[time.Time]BookmarkInfo
|
||||
FileSize int
|
||||
IndexSize int
|
||||
Searches int
|
||||
}
|
||||
|
||||
type BookmarkInfo struct {
|
||||
Bookmarks int
|
||||
IndexedWords int
|
||||
Bookmarks int
|
||||
}
|
||||
|
||||
func (stats DBStats) String() string {
|
||||
@@ -29,7 +29,7 @@ func (stats DBStats) String() string {
|
||||
sort.Slice(dates, func(i, j int) bool { return dates[i].Before(dates[j]) })
|
||||
|
||||
for _, k := range dates {
|
||||
out += fmt.Sprintf("%s - %d bookmarks, %d words indexed\n", k, stats.History[k].Bookmarks, stats.History[k].IndexedWords)
|
||||
out += fmt.Sprintf("%s - %d bookmarks\n", k, stats.History[k].Bookmarks)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user