Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can β€” learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company πŸ‘‡

fix(monitor/backend): gdelt switch to timelinevol mode (article-snippet source of malformed escapes is gone)

CarterPerez-dev038de64605d6
diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client.go b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client.go
index 745a3742..76d6d1e5 100644
--- a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client.go
+++ b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client.go
@@ -77,7 +77,7 @@ type rawTimeline struct {
func (c *Client) FetchTheme(ctx context.Context, theme string) ([]ThemeBucket, error) {
q := url.Values{}
q.Set("query", "theme:"+theme)
- q.Set("mode", "timelinevolinfo")
+ q.Set("mode", "timelinevol")
q.Set("TIMELINESMOOTH", "5")
q.Set("format", "json")
q.Set("timespan", "1d")
diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client_test.go b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client_test.go
index 0f7e4c26..b3f02d6e 100644
--- a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client_test.go
+++ b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/client_test.go
@@ -17,12 +17,13 @@ import (
)
func TestClient_FetchThemeDecodesBuckets(t *testing.T) {
- body, err := os.ReadFile("testdata/timelinevolinfo.json")
+ body, err := os.ReadFile("testdata/timelinevol.json")
require.NoError(t, err)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "/api/v2/doc/doc", r.URL.Path)
require.Equal(t, "theme:NATURAL_DISASTER", r.URL.Query().Get("query"))
+ require.Equal(t, "timelinevol", r.URL.Query().Get("mode"))
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write(body)
}))
diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/testdata/timelinevolinfo.json b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/testdata/timelinevol.json
similarity index 100%
rename from PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/testdata/timelinevolinfo.json
rename to PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/gdelt/testdata/timelinevol.json