From 4feece64ad7b1cb45f446eed3d693bad82e10857 Mon Sep 17 00:00:00 2001 From: lgflorentino <82384021+lgflorentino@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:38:29 +1000 Subject: [PATCH] fix the repo always directing db to bb-events --- lib/activity_monitor/db/repos/cb_repo.rb | 4 +++- lib/activity_monitor/db/repos/gh_repo.rb | 2 ++ lib/activity_monitor/db/repos/gl_repo.rb | 2 +- lib/activity_monitor/db/repos/sh_repo.rb | 1 + lib/activity_monitor/routing/default_router.rb | 1 + lib/activity_monitor/services/bitbucket.rb | 3 +-- lib/activity_monitor/services/service.rb | 5 ++--- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/activity_monitor/db/repos/cb_repo.rb b/lib/activity_monitor/db/repos/cb_repo.rb index 8c3b6ee..7e32de2 100644 --- a/lib/activity_monitor/db/repos/cb_repo.rb +++ b/lib/activity_monitor/db/repos/cb_repo.rb @@ -8,7 +8,9 @@ module Repos # Service repo for the Codeberg service. class CBRepo < ROM::Repository[:cb_events] - + + commands :create + end end end diff --git a/lib/activity_monitor/db/repos/gh_repo.rb b/lib/activity_monitor/db/repos/gh_repo.rb index 0c17a63..9db3064 100644 --- a/lib/activity_monitor/db/repos/gh_repo.rb +++ b/lib/activity_monitor/db/repos/gh_repo.rb @@ -8,6 +8,8 @@ module Repos # Service repo for the Github service. class GHRepo < ROM::Repository[:gh_events] + + commands :create end end diff --git a/lib/activity_monitor/db/repos/gl_repo.rb b/lib/activity_monitor/db/repos/gl_repo.rb index 2ead442..03ef275 100644 --- a/lib/activity_monitor/db/repos/gl_repo.rb +++ b/lib/activity_monitor/db/repos/gl_repo.rb @@ -7,7 +7,7 @@ module DB module Repos # Service repo for the Gitlab service. class GLRepo < ROM::Repository[:gl_events] - + commands :create end end end diff --git a/lib/activity_monitor/db/repos/sh_repo.rb b/lib/activity_monitor/db/repos/sh_repo.rb index ba43ff8..845874f 100644 --- a/lib/activity_monitor/db/repos/sh_repo.rb +++ b/lib/activity_monitor/db/repos/sh_repo.rb @@ -7,6 +7,7 @@ module DB module Repos # Service repo for the Source Hut service. class SHRepo < ROM::Repository[:sh_events] + commands :create end end end diff --git a/lib/activity_monitor/routing/default_router.rb b/lib/activity_monitor/routing/default_router.rb index 9a8d334..c1316e0 100644 --- a/lib/activity_monitor/routing/default_router.rb +++ b/lib/activity_monitor/routing/default_router.rb @@ -26,6 +26,7 @@ def match_request(*args, **kws) slug_re = %r{^*/#{route[1]}/*} if slug_re.match?(path_info) resp = process_request(route[0], env: args[0]) + log.debug "Matched request: #{route[0]} with #{path_info}" break end end diff --git a/lib/activity_monitor/services/bitbucket.rb b/lib/activity_monitor/services/bitbucket.rb index 58cd66f..e623de4 100644 --- a/lib/activity_monitor/services/bitbucket.rb +++ b/lib/activity_monitor/services/bitbucket.rb @@ -3,10 +3,9 @@ module ActivityMonitor module Services class Bitbucket < ActivityMonitor::Services::Service - NAME = Bitbucket def initialize - super + @service_name = "bitbucket" end end end diff --git a/lib/activity_monitor/services/service.rb b/lib/activity_monitor/services/service.rb index 2dbf952..331aecf 100644 --- a/lib/activity_monitor/services/service.rb +++ b/lib/activity_monitor/services/service.rb @@ -5,15 +5,14 @@ module Services class Service include ActivityMonitor::Logging - SERVICE_NAME = "super" - def initialize() + @service_name = "default" end def call(*args, **kws, &blk); end def db_setup(db: nil) - @repo = DB::Repos::BBRepo.new(db) + @repo = DB::Repos.init_repo(service_name: @service_name, db: db) end def process_event(content)