From ed7e6e0f337a35be94d8c53c69bfe14d1472cb79 Mon Sep 17 00:00:00 2001 From: Anton Berezhnyi Date: Thu, 12 Oct 2023 11:25:31 +0300 Subject: [PATCH] Add source realtime --- deletedScoresImporter.go | 1 + deletedScoresImporter_test.go | 9 ++++++--- go.mod | 2 +- go.sum | 10 ++-------- updatedScoresImporter.go | 1 + updatedScoresImporter_test.go | 12 ++++++++---- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/deletedScoresImporter.go b/deletedScoresImporter.go index e531294..1d59c34 100644 --- a/deletedScoresImporter.go +++ b/deletedScoresImporter.go @@ -124,6 +124,7 @@ func (importer *DeletedScoresImporter) pullDeletedScores() error { var event events.ScoreEvent event.SyncedAt = time.Now() + event.ScoreSource = events.Realtime for rows.Next() { err = rows.Scan( &event.Id, &event.StudentId, diff --git a/deletedScoresImporter_test.go b/deletedScoresImporter_test.go index d41c268..783a5f4 100644 --- a/deletedScoresImporter_test.go +++ b/deletedScoresImporter_test.go @@ -57,7 +57,8 @@ func TestExecuteImportDeletedScores(t *testing.T) { IsAbsent: false, IsDeleted: true, }, - SyncedAt: syncedAtRewrite, + SyncedAt: syncedAtRewrite, + ScoreSource: events.Realtime, } lessonDeletedEvent := dekanatEvents.LessonDeletedEvent{ @@ -132,7 +133,8 @@ func TestExecuteImportDeletedScores(t *testing.T) { IsAbsent: false, IsDeleted: false, }, - SyncedAt: syncedAtRewrite, + SyncedAt: syncedAtRewrite, + ScoreSource: events.Realtime, } lessonDeletedEvent := dekanatEvents.LessonDeletedEvent{ @@ -210,7 +212,8 @@ func TestExecuteImportDeletedScores(t *testing.T) { IsAbsent: false, IsDeleted: false, }, - SyncedAt: syncedAtRewrite, + SyncedAt: syncedAtRewrite, + ScoreSource: events.Realtime, } lessonDeletedEvent := dekanatEvents.LessonDeletedEvent{ diff --git a/go.mod b/go.mod index 4ecd858..cc45f40 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sqs v1.24.5 github.com/joho/godotenv v1.4.0 github.com/kneu-messenger-pigeon/dekanat-events v0.1.5 - github.com/kneu-messenger-pigeon/events v0.1.40 + github.com/kneu-messenger-pigeon/events v0.1.41 github.com/kneu-messenger-pigeon/fileStorage v1.0.1 github.com/mattn/go-sqlite3 v1.14.16 github.com/nakagami/firebirdsql v0.9.4 diff --git a/go.sum b/go.sum index fb6eb2d..087fc90 100644 --- a/go.sum +++ b/go.sum @@ -47,16 +47,10 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.1 h1:XsoYyvqmahJmZrhR4/0Jw6/h+5bmvz+VzKuL/2l9GHs= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.1/go.mod h1:KC0hflA3057dtpg2Mtpbhma9Z3n8Y43vwyygZODzO/Y= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.2 h1:fqWPIB8/RUN54/RJxpkmsSyGHwMhkR++WJbdI6+11pE= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.2/go.mod h1:KC0hflA3057dtpg2Mtpbhma9Z3n8Y43vwyygZODzO/Y= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.3 h1:RqsPXCrBjkONEaYPPTo5W3q9FULSjRi6qNUDnoBYI54= -github.com/kneu-messenger-pigeon/dekanat-events v0.1.3/go.mod h1:KC0hflA3057dtpg2Mtpbhma9Z3n8Y43vwyygZODzO/Y= github.com/kneu-messenger-pigeon/dekanat-events v0.1.5 h1:nmNFE/zaZtFkeLrlXrxBk1kQrZ8/pe00c228uWeERsQ= github.com/kneu-messenger-pigeon/dekanat-events v0.1.5/go.mod h1:KC0hflA3057dtpg2Mtpbhma9Z3n8Y43vwyygZODzO/Y= -github.com/kneu-messenger-pigeon/events v0.1.40 h1:Ov5Ny7h5KGmxMFT5k6UPikun+LeQEymdIe3aATuzcRo= -github.com/kneu-messenger-pigeon/events v0.1.40/go.mod h1:Q6X8B9gKZpKbby9gisLumvGT1xCWBM7bAFnviYi6MBQ= +github.com/kneu-messenger-pigeon/events v0.1.41 h1:Yzzp7oyVArzKzzI93HmLX+k3lUn8E3dKUk9uNF3le+8= +github.com/kneu-messenger-pigeon/events v0.1.41/go.mod h1:Q6X8B9gKZpKbby9gisLumvGT1xCWBM7bAFnviYi6MBQ= github.com/kneu-messenger-pigeon/fileStorage v1.0.1 h1:9ncIZaUXDv5SwB5KtWae/CSYYye1m/z4R7hU1WmBnWQ= github.com/kneu-messenger-pigeon/fileStorage v1.0.1/go.mod h1:v6IRKfG5C45B6Ls6781bmnLNwAE3e6ZcWuU0N55l66M= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= diff --git a/updatedScoresImporter.go b/updatedScoresImporter.go index 7b26287..c969144 100644 --- a/updatedScoresImporter.go +++ b/updatedScoresImporter.go @@ -122,6 +122,7 @@ func (importer *UpdatedScoresImporter) pullUpdatedScores() error { } var event events.ScoreEvent event.SyncedAt = time.Now() + event.ScoreSource = events.Realtime nextLastRegDate := importer.getLastRegDate() for rows.Next() { err = rows.Scan( diff --git a/updatedScoresImporter_test.go b/updatedScoresImporter_test.go index 6387143..672dc6a 100644 --- a/updatedScoresImporter_test.go +++ b/updatedScoresImporter_test.go @@ -69,7 +69,8 @@ func TestExecuteImportUpdatedScores(t *testing.T) { IsAbsent: false, IsDeleted: true, }, - SyncedAt: syncedAtRewrite, + SyncedAt: syncedAtRewrite, + ScoreSource: events.Realtime, } updatedScoreEvent := dekanatEvents.ScoreEditEvent{ @@ -154,7 +155,8 @@ func TestExecuteImportUpdatedScores(t *testing.T) { IsAbsent: false, IsDeleted: false, }, - SyncedAt: syncedAtRewrite, + SyncedAt: syncedAtRewrite, + ScoreSource: events.Realtime, } updateScoreEvent := dekanatEvents.ScoreEditEvent{ @@ -232,8 +234,9 @@ func TestExecuteImportUpdatedScores(t *testing.T) { IsAbsent: false, IsDeleted: false, }, - SyncedAt: syncedAtRewrite, - UpdatedAt: syncedAtRewrite.Add(-time.Minute), + SyncedAt: syncedAtRewrite, + UpdatedAt: syncedAtRewrite.Add(-time.Minute), + ScoreSource: events.Realtime, } updateScoreEvent := dekanatEvents.ScoreEditEvent{ @@ -335,6 +338,7 @@ func TestImportUpdatedScoresLesson(t *testing.T) { IsAbsent: false, IsDeleted: false, }, + ScoreSource: events.Realtime, } updateScoreEvent := dekanatEvents.ScoreEditEvent{