Skip to content

Commit

Permalink
Revert "170 2 adjust event only to fire when due (#664)"
Browse files Browse the repository at this point in the history
This reverts commit 853534a.
  • Loading branch information
adrian-codecov authored Sep 3, 2024
1 parent 5bd9181 commit 29f2935
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
11 changes: 3 additions & 8 deletions database/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from google.cloud import pubsub_v1
from shared.config import get_config
from sqlalchemy import event, inspect
from sqlalchemy import event

from database.models.core import Repository

Expand Down Expand Up @@ -51,10 +51,5 @@ def after_insert_repo(mapper, connection, target):

@event.listens_for(Repository, "after_update")
def after_update_repo(mapper, connection, target):
state = inspect(target)

for attr in state.attrs:
if attr.key in ["name", "upload_token"] and attr.history.has_changes():
log.info("After update signal")
_sync_repo(target)
break
log.info("After update signal")
_sync_repo(target)
1 change: 0 additions & 1 deletion database/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class Repository(CodecovBaseModel):
random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
),
)
upload_token = Column(postgresql.UUID)
language = Column(types.Text)
languages = Column(postgresql.ARRAY(types.String), nullable=True, default=[])
languages_last_updated = Column(types.DateTime, server_default=FetchedValue())
Expand Down
5 changes: 0 additions & 5 deletions database/tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ def test_shelter_repo_sync(dbsession, mock_configuration, mocker):
repo.name = "testing"
dbsession.commit()

# this wouldn't trigger the publish via SQLAlchemy events (after_update) since it's an unimportant attribute
repo.activated = True
dbsession.commit()

# this is from the first trigger
publish.assert_called_once_with(
"projects/test-project-id/topics/test-topic-id",
b'{"type": "repo", "sync": "one", "id": 91728376}',
Expand Down

0 comments on commit 29f2935

Please sign in to comment.