Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-127004

Liferay DXP 7.3 GA1 AssetEntry's viewCount issue

    Details

    • Type: Regression Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 7.3.10 DXP GA1
    • Fix Version/s: None
    • Component/s: Asset Framework
    • Labels:

      Description

      Hello,

       

      I found an issue with viewCount field in Liferay DXP 7.3. We use that field in one of our projects for displaying purposes. What I noticed is that when I migrated the Liferay from 7.0.6 GA7 CE to 7.3 GA1 DXP all assets had this number set to "0".

      After investigating the issue it seems that before the information was hold in AssetEntry.viewCount:

       

      select viewCount from AssetEntry
      

      After migration this field still exists but Liferay uses another table called "ViewCountEntry" instead. I turned on logging of the SQL queries and while fetching an AssetEntry and calling for that field I can notice following sql:

       

      select viewcounte0_.companyId as companyId613_0_, viewcounte0_.classNameId as classNam2_613_0_, viewcounte0_.classPK as classPK613_0_, viewcounte0_.viewCount as viewCount613_0_ from ViewCountEntry viewcounte0_ where viewcounte0_.companyId=? and viewcounte0_.classNameId=? and viewcounte0_.classPK=?
      

      I also verified that in code - there is following method:

      public long getViewCount() {
              return ViewCountManagerUtil.getViewCount(
                  getCompanyId(),
                  ClassNameLocalServiceUtil.getClassNameId(AssetEntry.class),
                  getPrimaryKey());
          }
      

      But when I checked the migrated database that table was empty. So the issue is that the migration tool doesn't copy values from old AssetEntry table to the new ViewCountEntry table.

       

      Issue2: there is also second issue connected to this. As a workaround I basically copied the values with SQL script as it was easier than waiting for the migration tool update.

      The SQL I used was following:

      INSERT INTO ViewCountEntry
      select companyId,
       (SELECT classNameId FROM ClassName_ where value = 'com.liferay.asset.kernel.model.AssetEntry') as classNameId,
       entryId,
       viewCount from AssetEntry;
      

      And it worked - I could see the numbers as I did in Liferay 7.0.6. Unfortunately another issue appeared - this table is not updated while visting a page where the AssetEntry is present. No matter how many times I enter the page the number stays the same. Again I found a workaround to use ViewCountManagerUtil.incrementViewCount when visiting the page but this is not the best as in my case it was quite easy because I just had to update single FTL template but if someone needed to count assets from many different places then it would be a nightmare.

       

      Note: please note for the second issue I only tested the JournalArticle (Web Content) assets. I haven't done additional tests for another kind of assets.

      The first issue occurs to all kinds though as I had many different and no values were copied at all.

       

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            rpydyniak Rafał Pydyniak
            Participants of an Issue:
            Recent user:
            Oziel Souza
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              10 weeks, 5 days ago

                Packages

                Version Package