Bug 363611 - ratings don't work from packagekit component
Summary: ratings don't work from packagekit component
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: PackageKit (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-27 22:29 UTC by Jonathan Riddell
Modified: 2016-06-02 14:13 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Riddell 2016-05-27 22:29:03 UTC
Ratings for applications don't work (it just lists the ratings from Plasma widgets).
This is using the Packagekit backend and the ubuntu repository appstream data.
bug 343084 is a problem in the qapt backend but I guess that's separate code from Packagekit


Reproducible: Always
Comment 1 Jonathan Riddell 2016-05-27 22:32:18 UTC
some appstream data is generated by aleix at http://appstream.kubuntu.co.uk/ (converted from popcon) so the question is how to wire that up to neon's appstream data
Comment 2 Aleix Pol 2016-05-28 01:46:38 UTC
Here it's explained a bit, you can see how it's generated a bit in the readme. Is there neon popcon? https://github.com/aleixpol/AppstreamPopcon

By the way, I can't connect to that server anymore. :/
Comment 3 Aleix Pol 2016-05-28 01:55:38 UTC
FWIW, this should work on neon too, it will just show data from Debian/Ubuntu.

Likewise, when Discover is shown nowadays, it shows the popcon data from these distros.
Comment 4 Jonathan Riddell 2016-05-29 10:58:57 UTC
Looking at the code I see it hardcodes the URL and that is downloaded into /home/jr/.cache/muondiscover/appstream-popcon.gz fine however it looks like Discover isn't picking up those ratings as all apps have zero stars showing.

How can we debug why it's not picking up those ratings?
Comment 5 Aleix Pol 2016-05-31 13:49:14 UTC
Maybe you can check whether it's being loaded. FWIW I tested Neon and it works for me.
Another thing you can check is whether the downloaded file is valid.

diff --git a/libdiscover/backends/PackageKitBackend/AppstreamReviews.cpp b/libdiscover/backends/PackageKitBackend/AppstreamReviews.cpp
index 2f5bd02..8d2552c 100644
--- a/libdiscover/backends/PackageKitBackend/AppstreamReviews.cpp
+++ b/libdiscover/backends/PackageKitBackend/AppstreamReviews.cpp
@@ -64,6 +64,7 @@ void AppstreamReviews::ratingsFetched(KJob* job)
 
 void AppstreamReviews::readRatings()
 {
+    qDebug() << "reading ratings..." << ratingsCache->toLocalFile();
     QScopedPointer<QIODevice> dev(new KCompressionDevice(ratingsCache->toLocalFile(), KCompressionDevice::GZip));
     if (!dev->open(QIODevice::ReadOnly)) {
         qWarning() << "couldn't open popcon file" << dev->errorString();
Comment 6 Jonathan Riddell 2016-06-01 09:04:07 UTC
Added that and compiled it and on running it does output
reading ratings... "/home/jr/.cache/muondiscover/appstream-popcon.gz"
but the ratings box doesn't show any apps and searching for e.g. konsole shows it has 0 stars
Comment 7 Jonathan Riddell 2016-06-01 09:46:25 UTC
Adding some more debugging it does seem to successfully read the popcon file

In PopConParser.cpp
QHash<QString, Rating *> PopConParser::parsePopcon(QObject* parent, QIODevice* dev)
Added: qDebug() << "XXXadding ratings" << pkgName << " " << vote;
I can see:
XXXadding ratings "org.kde.konsole.desktop"   503916

But in AppstreamReviews.cpp
Rating * AppstreamReviews::ratingForApplication(AbstractResource* app) const
I re-enable the debug line qDebug() << "fuuuuuu" << appk->appstreamId() << m_ratings.value(appk->appstreamId());
and add
qDebug() << " " << m_ratings.value(appk->appstreamId())->rating();
it show:
fuuuuuu "org.kde.konsole.desktop" Rating(0x5a90120)
"org.kde.konsole.desktop"   0

so something is wiping the ratings
and it shows
Comment 8 Jonathan Riddell 2016-06-01 10:10:35 UTC
the key apol@oliver is in authorized_keys for  ssh ubuntu@appstream.kubuntu.co.uk, does that work?
Comment 9 Aleix Pol 2016-06-01 13:46:00 UTC
Yes it does, sorry, I forgot the ubuntu@.

I'll investigate more, thanks for checking.
Comment 10 Aleix Pol 2016-06-01 15:10:39 UTC
At the moment we are not serving the rating property, because we don't actually have data for the rating.

We're just filling the ratingCount, which is the number of installations provided by popcon. We need to find a way to have ratings.
Comment 11 Jonathan Riddell 2016-06-01 17:40:45 UTC
Ah hah, can we hide the Ratings box on the front page until that gets implemented?
Comment 12 Aleix Pol 2016-06-02 14:13:47 UTC
Git commit 88c09c19d4260494d4626ca85a9575529d697dfb by Aleix Pol.
Committed on 02/06/2016 at 14:13.
Pushed by apol into branch 'master'.

Don't show the stars if there's a null rating

M  +2    -3    discover/qml/Rating.qml

http://commits.kde.org/discover/88c09c19d4260494d4626ca85a9575529d697dfb