Skip to content
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

Revert "170 2 adjust event only to fire when due" #678

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading