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

BETA flag not shown #140

Open
hgy59 opened this issue Jan 18, 2025 · 3 comments · May be fixed by #141
Open

BETA flag not shown #140

hgy59 opened this issue Jan 18, 2025 · 3 comments · May be fixed by #141

Comments

@hgy59
Copy link
Contributor

hgy59 commented Jan 18, 2025

BETA flag is not shown on some package versions.

See monit package.
All three revisions (7, 8, 10) are BETA, but only revisions 7 and 8 are displayed with betaLabel, revision 10 is missing this label.

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 18, 2025

@mreid-tt any idea what's going wrong?

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 18, 2025

Just uploaded revision 11 and it has the label (revision 10 is still missing it).

@mreid-tt
Copy link
Contributor

mreid-tt commented Jan 18, 2025

@hgy59 this seems to be a side-effect of how we define beta versions. Technically there are two fields related to beta packages in the DSM developer guide:

Field Name: beta

  • Description: If this package is considered the beta version, the beta information will be shown in Package Center.
  • Value: "yes"/"no"
  • Default Value: "no"
  • Example: None
  • DSM Requirement: 6.0

Field Name: report_url

  • Description: If a package is a beta version and has a "report" webpage, Package Center will display a hyperlink. If this package is considered the beta version, the beta information will be also be shown in Package Center.
  • Value: String
  • Default Value: (Empty)
  • Example: None
  • DSM Requirement: 3.2-1922

The problem is that in our database schema we only define the report_url:

spkrepo/spkrepo/models.py

Lines 402 to 411 in 2b4012b

class Version(db.Model):
__tablename__ = "version"
# Columns
id = db.Column(db.Integer, primary_key=True)
package_id = db.Column(db.Integer, db.ForeignKey("package.id"), nullable=False)
version = db.Column(db.Integer, nullable=False, index=True)
upstream_version = db.Column(db.Unicode(20), nullable=False)
changelog = db.Column(db.UnicodeText)
report_url = db.Column(db.Unicode(255))

The field for beta is actually derived based on the report_url:

spkrepo/spkrepo/models.py

Lines 463 to 465 in 2b4012b

@hybrid_property
def beta(self):
return self.report_url != None # noqa: E711

Now this creates a dependency in our packages for the value of beta to be based on report_url which isn't the case in the DSM developer guide. We have however codified this into our Makefile variable handling:

spksrc/mk/spksrc.spk.mk (L208-L210)

ifneq ($(strip $(BETA)),)
	@echo beta=\"yes\" >> $@
	@echo report_url=\"$(REPORT_URL)\" >> $@

The challenge is that when monit revision 10 was published the Info file contained the following:

beta="yes"
report_url=""

This structure should not exist based on how our Makefile variables are handled. Revision 11 has it correct as follows:

beta="yes"
report_url="https://github.com/SynoCommunity/spksrc/issues"

Now, within the admin interface it lists it as a beta because the view is initialised based on the model above:

class VersionView(ModelView):
"""View for :class:`~spkrepo.models.Version`"""
def __init__(self, **kwargs):
super(VersionView, self).__init__(Version, db.session, **kwargs)

Then we have the specific columns:

# View
column_list = (
"package",
"upstream_version",
"version",
"beta",

So it would be using the synthetic field for beta as noted before.

Now this is different than what is done in the front-end interface with this code block:

<dt>Version {{ version.version_string | safe }}{% if version.report_url %} <span class="label label-danger">beta</span>{% endif %}</dt>

As you can see it is querying the version.report_url field directly. This would also be consistent with how the Package Center queries beta packages as follows:

if not beta:
latest_version = latest_version.filter(Version.report_url.is_(None))

if b.version.report_url:
entry["report_url"] = b.version.report_url
entry["beta"] = True

My guess is that the synthetic beta field used by the admin interface is returning True when it should return False since the value of report_url is empty. It's possible that and empty string may not equate to None but I'll need to do some more testing to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants