-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add location information to timeline #59
Changes from 5 commits
65a6148
1fd4f6d
b7cbb32
56191c2
18400e2
d7c78e5
1168370
d89cb90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||||||||||
ALTER TABLE infos DROP COLUMN "longitude" text; | ||||||||||||||
ALTER TABLE infos DROP COLUMN "latitude" text; | ||||||||||||||
ALTER TABLE infos DROP COLUMN "location" text; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Types are not needed while dropping columns.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE infos ADD COLUMN "longitude" numeric; | ||
ALTER TABLE infos ADD COLUMN "latitude" numeric; | ||
ALTER TABLE infos ADD COLUMN "location" text; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,8 @@ import ( | |||||
"github.com/docker/go-units" | ||||||
"github.com/prometheus/client_golang/prometheus" | ||||||
"github.com/prometheus/client_golang/prometheus/promauto" | ||||||
|
||||||
"github.com/sams96/rgeo" | ||||||
) | ||||||
|
||||||
var ErrNotFound = errors.New("not found") | ||||||
|
@@ -140,6 +142,7 @@ type Source struct { | |||||
|
||||||
decoder *Decoder | ||||||
database *Database | ||||||
rg *rgeo.Rgeo | ||||||
|
||||||
imageInfoCache InfoCache | ||||||
pathCache PathCache | ||||||
|
@@ -161,6 +164,15 @@ func NewSource(config Config, migrations embed.FS, migrationsThumbs embed.FS) *S | |||||
source.database = NewDatabase(filepath.Join(config.DataDir, "photofield.cache.db"), migrations) | ||||||
source.imageInfoCache = newInfoCache() | ||||||
source.pathCache = newPathCache() | ||||||
|
||||||
r, err := rgeo.New(rgeo.Provinces10, rgeo.Cities10) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This takes about half a minute to init on my (admittedly quite old) PC. Maybe a good idea would be to load it async (e.g. in a goroutine) just so that restarts don't take that long? Alternatively |
||||||
|
||||||
if err != nil { | ||||||
// Handle error | ||||||
fmt.Println("RGEO ERR", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
source.rg = r | ||||||
} | ||||||
|
||||||
source.SourceLatencyHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ | ||||||
Namespace: metrics.Namespace, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rgeo
seems to be fast enough that the location text itself might not even need to be cached? In my quick profiling the reverse geocoding almost doesn't show up. Instead it could happen at "layout-time".