mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Add outdated flag to UpdateConfig to stop notification spam
This commit is contained in:
parent
c8406b45d4
commit
09a9219fcd
@ -856,6 +856,10 @@ class PackageRelease(db.Model):
|
|||||||
assert self.task_id is None and self.url is not None and self.url != ""
|
assert self.task_id is None and self.url is not None and self.url != ""
|
||||||
|
|
||||||
self.approved = True
|
self.approved = True
|
||||||
|
|
||||||
|
if self.package.update_config:
|
||||||
|
self.package.update_config.outdated = False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def checkPerm(self, user, perm):
|
def checkPerm(self, user, perm):
|
||||||
@ -948,5 +952,8 @@ class PackageUpdateConfig(db.Model):
|
|||||||
|
|
||||||
last_commit = db.Column(db.String(41), nullable=True, default=None)
|
last_commit = db.Column(db.String(41), nullable=True, default=None)
|
||||||
|
|
||||||
|
# Set to true when an outdated notification is sent. Set to false when a release is created
|
||||||
|
outdated = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
trigger = db.Column(db.Enum(PackageUpdateTrigger), nullable=False, default=PackageUpdateTrigger.COMMIT)
|
trigger = db.Column(db.Enum(PackageUpdateTrigger), nullable=False, default=PackageUpdateTrigger.COMMIT)
|
||||||
make_release = db.Column(db.Boolean, nullable=False, default=False)
|
make_release = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
@ -323,24 +323,33 @@ def check_update_config(package_id):
|
|||||||
|
|
||||||
config = package.update_config
|
config = package.update_config
|
||||||
ref = None
|
ref = None
|
||||||
|
|
||||||
hash = get_commit_hash(package.repo, ref)
|
hash = get_commit_hash(package.repo, ref)
|
||||||
|
if config.last_commit == hash:
|
||||||
|
return
|
||||||
|
|
||||||
if config.last_commit != hash:
|
if not config.last_commit:
|
||||||
if config.make_release:
|
config.last_commit = hash
|
||||||
rel = PackageRelease()
|
db.session.commit()
|
||||||
rel.package = package
|
return
|
||||||
rel.title = hash[0:5]
|
|
||||||
rel.url = ""
|
|
||||||
rel.task_id = uuid()
|
|
||||||
db.session.add(rel)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
makeVCSRelease.apply_async((rel.id, ref), task_id=rel.task_id)
|
if config.make_release:
|
||||||
|
rel = PackageRelease()
|
||||||
|
rel.package = package
|
||||||
|
rel.title = hash[0:5]
|
||||||
|
rel.url = ""
|
||||||
|
rel.task_id = uuid()
|
||||||
|
db.session.add(rel)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
else:
|
makeVCSRelease.apply_async((rel.id, ref), task_id=rel.task_id)
|
||||||
post_system_thread(package, "New commit detected, package outdated?",
|
|
||||||
"Commit {} was detected on the Git repository.\n\n[Change update configuration]({})" \
|
elif not config.outdated:
|
||||||
.format(hash[0:5], package.getUpdateConfigURL()))
|
config.outdated = True
|
||||||
|
|
||||||
|
post_system_thread(package, "New commit detected, package outdated?",
|
||||||
|
"Commit {} was detected on the Git repository.\n\n[Change update configuration]({})" \
|
||||||
|
.format(hash[0:5], package.getUpdateConfigURL()))
|
||||||
|
|
||||||
config.last_commit = hash
|
config.last_commit = hash
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
24
migrations/versions/4585ce5147b8_.py
Normal file
24
migrations/versions/4585ce5147b8_.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 4585ce5147b8
|
||||||
|
Revises: 105d4c740ad6
|
||||||
|
Create Date: 2020-12-15 21:35:18.982716
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '4585ce5147b8'
|
||||||
|
down_revision = '105d4c740ad6'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column('package_update_config', sa.Column('outdated', sa.Boolean(), nullable=False, server_default="false"))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column('package_update_config', 'outdated')
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Create a database migration, and copy it back to the host.
|
# Create a database migration, and copy it back to the host.
|
||||||
|
|
||||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db revision"
|
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate"
|
||||||
docker exec -u root contentdb_app_1 sh -c "cp /home/cdb/migrations/versions/* /source/migrations/versions/"
|
docker exec -u root contentdb_app_1 sh -c "cp /home/cdb/migrations/versions/* /source/migrations/versions/"
|
||||||
|
|
||||||
USER=$(whoami)
|
USER=$(whoami)
|
||||||
|
Loading…
Reference in New Issue
Block a user