mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12: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,9 +323,16 @@ 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)
|
|
||||||
|
|
||||||
if config.last_commit != hash:
|
hash = get_commit_hash(package.repo, ref)
|
||||||
|
if config.last_commit == hash:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not config.last_commit:
|
||||||
|
config.last_commit = hash
|
||||||
|
db.session.commit()
|
||||||
|
return
|
||||||
|
|
||||||
if config.make_release:
|
if config.make_release:
|
||||||
rel = PackageRelease()
|
rel = PackageRelease()
|
||||||
rel.package = package
|
rel.package = package
|
||||||
@ -337,7 +344,9 @@ def check_update_config(package_id):
|
|||||||
|
|
||||||
makeVCSRelease.apply_async((rel.id, ref), task_id=rel.task_id)
|
makeVCSRelease.apply_async((rel.id, ref), task_id=rel.task_id)
|
||||||
|
|
||||||
else:
|
elif not config.outdated:
|
||||||
|
config.outdated = True
|
||||||
|
|
||||||
post_system_thread(package, "New commit detected, package outdated?",
|
post_system_thread(package, "New commit detected, package outdated?",
|
||||||
"Commit {} was detected on the Git repository.\n\n[Change update configuration]({})" \
|
"Commit {} was detected on the Git repository.\n\n[Change update configuration]({})" \
|
||||||
.format(hash[0:5], package.getUpdateConfigURL()))
|
.format(hash[0:5], package.getUpdateConfigURL()))
|
||||||
|
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