Hello community, here is the log from the commit of package kactivities-stats for openSUSE:Factory checked in at 2017-09-19 16:21:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kactivities-stats (Old) and /work/SRC/openSUSE:Factory/.kactivities-stats.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kactivities-stats" Tue Sep 19 16:21:39 2017 rev:17 rq:526623 version:5.38.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kactivities-stats/kactivities-stats.changes 2017-08-24 17:55:40.412751058 +0200 +++ /work/SRC/openSUSE:Factory/.kactivities-stats.new/kactivities-stats.changes 2017-09-19 16:21:41.309773175 +0200 @@ -1,0 +2,13 @@ +Tue Sep 12 07:11:16 CEST 2017 - [email protected] + +- Update to 5.38.0 + * New feature release + * For more details please see: + * https://www.kde.org/announcements/kde-frameworks-5.38.0.php +- Changes since 5.37.0: + * Refactor of the query which combines linked and used resources + * Switched debugging output off + * Reloading the model when the resource gets unlinked + * Fixed the query when merging linked and used resources + +------------------------------------------------------------------- Old: ---- kactivities-stats-5.37.0.tar.xz New: ---- kactivities-stats-5.38.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kactivities-stats.spec ++++++ --- /var/tmp/diff_new_pack.ViXtGb/_old 2017-09-19 16:21:41.905689178 +0200 +++ /var/tmp/diff_new_pack.ViXtGb/_new 2017-09-19 16:21:41.905689178 +0200 @@ -17,11 +17,14 @@ %define lname libKF5ActivitiesStats1 -%define _tar_path 5.37 +%define _tar_path 5.38 +# Full KF5 version (e.g. 5.33.0) +%{!?_kf5_version: %global _kf5_version %{version}} +# Last major and minor KF5 version (e.g. 5.33) +%{!?_kf5_bugfix_version: %global _kf5_bugfix_version %(echo %{_kf5_version} | awk -F. '{print $1"."$2}')} Name: kactivities-stats -Version: 5.37.0 +Version: 5.38.0 Release: 0 -%define kf5_version %{version} Summary: KDE Plasma Activities support License: LGPL-2.0+ Group: System/Libraries @@ -34,12 +37,12 @@ BuildRequires: boost-devel %endif BuildRequires: cmake >= 3.0 -BuildRequires: extra-cmake-modules >= %{_tar_path} +BuildRequires: extra-cmake-modules >= %{_kf5_bugfix_version} BuildRequires: fdupes BuildRequires: kf5-filesystem BuildRequires: xz -BuildRequires: cmake(KF5Activities) >= %{_tar_path} -BuildRequires: cmake(KF5Config) >= %{_tar_path} +BuildRequires: cmake(KF5Activities) >= %{_kf5_bugfix_version} +BuildRequires: cmake(KF5Config) >= %{_kf5_bugfix_version} BuildRequires: cmake(Qt5Core) >= 5.3.0 BuildRequires: cmake(Qt5DBus) >= 5.3.0 BuildRequires: cmake(Qt5Sql) >= 5.3.0 ++++++ kactivities-stats-5.37.0.tar.xz -> kactivities-stats-5.38.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.37.0/CMakeLists.txt new/kactivities-stats-5.38.0/CMakeLists.txt --- old/kactivities-stats-5.37.0/CMakeLists.txt 2017-08-06 18:26:47.000000000 +0200 +++ new/kactivities-stats-5.38.0/CMakeLists.txt 2017-09-02 23:07:34.000000000 +0200 @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0) -set(KF5_VERSION "5.37.0") # handled by release scripts -set(KF5_DEP_VERSION "5.37.0") # handled by release scripts +set(KF5_VERSION "5.38.0") # handled by release scripts +set(KF5_DEP_VERSION "5.38.0") # handled by release scripts project (KActivitiesStats VERSION ${KF5_VERSION}) set (REQUIRED_QT_VERSION 5.7.0) @@ -20,7 +20,7 @@ # Extra CMake stuff include (FeatureSummary) -find_package (ECM 5.37.0 NO_MODULE) +find_package (ECM 5.38.0 NO_MODULE) set_package_properties (ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary (WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.37.0/src/resultmodel.cpp new/kactivities-stats-5.38.0/src/resultmodel.cpp --- old/kactivities-stats-5.37.0/src/resultmodel.cpp 2017-08-06 18:26:47.000000000 +0200 +++ new/kactivities-stats-5.38.0/src/resultmodel.cpp 2017-09-02 23:07:34.000000000 +0200 @@ -355,7 +355,8 @@ using namespace kamd::utils::member_matcher; #if 0 - QDBG << "===\nOld items {"; + QDBG << "======"; + QDBG << "Old items {"; for (const auto& item: m_items) { QDBG << item; } @@ -535,9 +536,15 @@ //_ Compartor that orders the linked items by user-specified order typedef kamd::utils::member_matcher::placeholder placeholder; - FixedItemsLessThan(const Cache &cache, + enum Ordering { + PartialOrdering, + FullOrdering + }; + + FixedItemsLessThan(Ordering ordering, + const Cache &cache, const QString &matchResource = QString()) - : cache(cache), matchResource(matchResource) + : cache(cache), matchResource(matchResource), ordering(ordering) { } @@ -555,7 +562,7 @@ ( hasLeft && !hasRight) ? true : (!hasLeft && hasRight) ? false : ( hasLeft && hasRight) ? indexLeft < indexRight : - leftResource < rightResource; + (ordering == PartialOrdering ? false : leftResource < rightResource); } template <typename T> @@ -578,6 +585,7 @@ const Cache &cache; const QString matchResource; + Ordering ordering; //^ }; @@ -592,16 +600,17 @@ const auto lastUpdate = result.lastUpdate(); const auto linkStatus = result.linkStatus(); + #define FIXED_ITEMS_LESS_THAN FixedItemsLessThan(FixedItemsLessThan::FullOrdering, cache, resource) #define ORDER_BY(Field) member(&ResultSet::Result::Field) > Field #define ORDER_BY_FULL(Field) \ (query.selection() == Terms::AllResources ? \ cache.lowerBoundWithSkippedResource( \ - FixedItemsLessThan(cache, resource) \ + FIXED_ITEMS_LESS_THAN \ && ORDER_BY(linkStatus) \ && ORDER_BY(Field) \ && ORDER_BY(resource)) : \ cache.lowerBoundWithSkippedResource( \ - FixedItemsLessThan(cache, resource) \ + FIXED_ITEMS_LESS_THAN \ && ORDER_BY(Field) \ && ORDER_BY(resource)) \ ) @@ -614,6 +623,7 @@ ; #undef ORDER_BY #undef ORDER_BY_FULL + #undef FIXED_ITEMS_LESS_THAN return destination; } @@ -726,10 +736,12 @@ hasMore = (it != results.end()); // We need to sort the new items for the linked resources - // user-defined reordering + // user-defined reordering. This needs only to be a partial sort, + // the main sorting is done by sqlite if (query.selection() != Terms::UsedResources) { - std::stable_sort(newItems.begin(), newItems.end(), - FixedItemsLessThan(cache)); + std::stable_sort( + newItems.begin(), newItems.end(), + FixedItemsLessThan(FixedItemsLessThan::PartialOrdering, cache)); } cache.replace(newItems, from); @@ -863,9 +875,9 @@ removeResult(result); } else if (query.selection() == Terms::AllResources) { - result->setLinkStatus(ResultSet::Result::NotLinked); - repositionResult(result, destinationFor(*result)); - + // When the result is unlinked, it might go away or not + // depending on its previous usage + reload(); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.37.0/src/resultset.cpp new/kactivities-stats-5.38.0/src/resultset.cpp --- old/kactivities-stats-5.37.0/src/resultset.cpp 2017-08-06 18:26:47.000000000 +0200 +++ new/kactivities-stats-5.38.0/src/resultset.cpp 2017-09-02 23:07:34.000000000 +0200 @@ -245,10 +245,10 @@ QStringList mimetypeFilter = transformedList( queryDefinition.types(), &ResultSetPrivate::mimetypeClause); - auto query = _query - + "\nORDER BY $orderingColumn resource ASC\n" - + limitOffsetSuffix(); + auto query = _query; + query.replace("ORDER_BY_CLAUSE", "ORDER BY $orderingColumn resource ASC") + .replace("LIMIT_CLAUSE", limitOffsetSuffix()); return kamd::utils::debug_and_return(DEBUG_QUERIES, "Query: ", query @@ -260,7 +260,7 @@ ); } - const QString &linkedResourcesQuery() const + static const QString &linkedResourcesQuery() { // TODO: We need to correct the scores based on the time that passed // since the cache was last updated, although, for this query, @@ -276,7 +276,7 @@ , rl.initiatingAgent as agent , COALESCE(ri.title, rl.targettedResource) as title , ri.mimetype as mimetype - , 2 as linkStatus + , 2 as linkStatus FROM ResourceLink rl @@ -296,13 +296,16 @@ AND ($mimetypeFilter) GROUP BY resource, title + + ORDER_BY_CLAUSE + LIMIT_CLAUSE )sql" ; return query; } - const QString &usedResourcesQuery() const + static const QString &usedResourcesQuery() { // TODO: We need to correct the scores based on the time that passed // since the cache was last updated @@ -317,7 +320,7 @@ , rsc.initiatingAgent as agent , COALESCE(ri.title, rsc.targettedResource) as title , ri.mimetype as mimetype - , 1 as linkStatus -- Note: this is replaced by allResourcesQuery + , 1 as linkStatus FROM ResourceScoreCache rsc @@ -332,41 +335,101 @@ AND ($mimetypeFilter) GROUP BY resource, title + + ORDER_BY_CLAUSE + LIMIT_CLAUSE )sql" ; return query; } - const QString &allResourcesQuery() const + static const QString &allResourcesQuery() { - // TODO: Implement counting of the linked items + // TODO: We need to correct the scores based on the time that passed + // since the cache was last updated, although, for this query, + // scores are not that important. + static const QString query = + R"sql( + WITH + LinkedResourcesResults AS ( + SELECT rl.targettedResource as resource + , rsc.cachedScore as score + , rsc.firstUpdate as firstUpdate + , rsc.lastUpdate as lastUpdate + , rl.usedActivity as activity + , rl.initiatingAgent as agent + , 2 as linkStatus + + FROM + ResourceLink rl + + LEFT JOIN + ResourceScoreCache rsc + ON rl.targettedResource = rsc.targettedResource + AND rl.usedActivity = rsc.usedActivity + AND rl.initiatingAgent = rsc.initiatingAgent + + WHERE + ($agentsFilter) + AND ($activitiesFilter) + AND ($urlFilter) + AND ($mimetypeFilter) + ), + + UsedResourcesResults AS ( + SELECT rsc.targettedResource as resource + , rsc.cachedScore as score + , rsc.firstUpdate as firstUpdate + , rsc.lastUpdate as lastUpdate + , rsc.usedActivity as activity + , rsc.initiatingAgent as agent + , 0 as linkStatus + + FROM + ResourceScoreCache rsc + + WHERE + ($agentsFilter) + AND ($activitiesFilter) + AND ($urlFilter) + AND ($mimetypeFilter) + ), + + CollectedResults AS ( + SELECT * + FROM LinkedResourcesResults + + UNION + + SELECT * + FROM UsedResourcesResults + WHERE resource NOT IN (SELECT resource FROM LinkedResourcesResults) + ) + + SELECT + resource + , SUM(score) as score + , MIN(firstUpdate) as firstUpdate + , MAX(lastUpdate) as lastUpdate + , activity + , agent + , COALESCE(ri.title, resource) as title + , ri.mimetype as mimetype + , linkStatus + + FROM CollectedResults cr + + LEFT JOIN + ResourceInfo ri + ON cr.resource = ri.targettedResource - // int linkedItemsCount = 0; - // - // if (linkedItemsCount >= limit) { - // return linkedResourcesQuery(); - // - // } else if (linkedItemsCount == 0) { - // return usedResourcesQuery(); - // - // } else { - - static QString usedResourcesQuery_ = usedResourcesQuery(); - - static const QString query = - "WITH LinkedResourcesResults as (\n" + - linkedResourcesQuery() + - "\n)\n" + - "SELECT * FROM LinkedResourcesResults \n" + - "UNION \n" + - usedResourcesQuery_ - .replace(QLatin1String("WHERE "), - QLatin1String("WHERE rsc.targettedResource NOT IN " - "(SELECT resource FROM LinkedResourcesResults) AND ")) - .replace(QLatin1String("1 as linkStatus"), QLatin1String("0 as linkStatus")); + GROUP BY resource, title - // } + ORDER_BY_CLAUSE + LIMIT_CLAUSE + )sql" + ; return query; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.37.0/src/utils/debug_and_return.h new/kactivities-stats-5.38.0/src/utils/debug_and_return.h --- old/kactivities-stats-5.37.0/src/utils/debug_and_return.h 2017-08-06 18:26:47.000000000 +0200 +++ new/kactivities-stats-5.38.0/src/utils/debug_and_return.h 2017-09-02 23:07:34.000000000 +0200 @@ -28,18 +28,9 @@ namespace utils { template<typename T> -T debug_and_return(const char * message, T && value) { - #ifdef QT_DEBUG - qDebug() << message << " " << value; - #endif - - return std::forward<T>(value); -} - -template<typename T> T debug_and_return(bool debug, const char * message, T && value) { if (debug) { - qDebug() << message << " " << value; + qDebug().noquote() << message << " " << value; } return std::forward<T>(value);
