Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago

How to show result after 1000 records. Its showing blank after 1000 records

Not showing result after 1000 records and showing empty result after 1000 records

Page call get only 1000 records. once record will go up it will get blank result to you.
There is 2 ways yo solve this but Iam not able to get the result for this.

1. write this query in API-V2
    <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page + '&page=' + y).notifications />
    
2. Write pagination for this. Following is the pagination I have implemented but it doesn't works for me.
    <#list 1..3 as y>
    <#assign page = notificationsPage * pageSize />
    <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page + '&page=' + y).notifications />
    </#list>
   

  • Hi Gyz, I gota fix for that. It might not be upto standard but it fixed my issue. Following is the snippet which shows only used notification instead of unused notification. Once it will go up 1000+ it will assign allnotification to 999. It works perfectely for me.

     

    <#assign _notificationsCount = restadmin( '/users/id/' + user.id + '/notifications/count' ).value?number />
                    <#if ( _notificationsCount > 999 )>    
                    <#assign _notificationsCount = 999 />
                    </#if>

     

    Note: Solution as per my requriement.

10 Replies

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi bhupen 

     

    I think you can increase these limits via a Support request. However the limits themselves are there for performance reasons, and therefore the question it's more whether you are using the right approach for the problem being solved. The pagination parameters are there exactly for this reasons (rather than pulling a very large quantity of data in one call).

     

    When you say that "it doesn't work" , what specifically is the problem you are running into? Is it an error, or the data being returned is not what you expect etc.. ?

     

    Thanks

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    PaoloTThanks,  my first preference is to solve this using APIV2.

     

    How to write following rest call with APIV2

     <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page + '&page=' + y).notifications />

     

    Second option: is to put into pagination. Following is the code where i put pagination but its  not working and nor showing any error.:

     <#list 1..3 as y>
        <#assign page = notificationsPage * pageSize />
        <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page + '&page=' + y).notifications />
        </#list>

     

     

    Red color text defined for pagination functionality.

    Help is appreciated.

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi bhupen 

     

    I don't think notifications are currently part of LiQL - so it is not possible to use API v2 to retrieve this information. If they were, you would probably use the LIMIT and OFFSET keywords to paginate (as for any LiQL query)

     

    Thanks,

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    PaoloT  okay fine. Can you please look into it why doesn't working this snippet for me. Although there is not showing any error.:

    <#list 1..3 as y>
        <#assign page = notificationsPage * pageSize />
        <#assign nots = restadmin( '/users/id/' + user.id + '/notifications?restapi.response_style=view&page_size=' + page + '&page=' + y).notifications />
        </#list>

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    bhupen responding very quickly here ... have you had a look at using 'offset' as you're using the API? I think I've provided some code in an earlier thread. Have a look if you can find it and if it helps.

     

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi bhupen 

     

    I suggest you raise a support ticket - I've tried with myself on the Lithium community (using page size = 1 and page 1,2,3 etc..) and I always get the same notification (the latest) back  irrispectively of the page number I pass, so it suggest that there may be an issue with the call itself.

     

    Thanks,

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    @OlivierS

    thanks for replying. Yes I tried some method but unofortunately couldn't get success. Can I have offset/code  example if you can provide.

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    bhupen not sure if it applies in this specific scenario, but please find below an example using the offset in LiQL:

     

    <#assign offsetmax=100/>
    <#assign stoploop=false/>
    <#list 0..offsetmax as i>
    <#assign offset=10*i />
    ${offset}
    <#assign apiVersion = "2.0"/>
    <#assign query = "SELECT id, body, subject, view_href, post_time, post_time_friendly, replies.count(*), kudos.sum(weight), author, board FROM messages WHERE depth=0 ORDER BY conversation.last_post_time DESC LIMIT 10 OFFSET ${offset}" />
    <#assign topics = rest(apiVersion, "/search?q=" + query?url).data.items![] />
    <ul>
    <#list topics as message>
    <#if message.post_time_friendly??>
    <#if (message.post_time_friendly?contains("m ago")) || (message.post_time_friendly?contains("h ago"))>
    <a href="${message.view_href}">${message.subject}</a>&nbsp;[${message.post_time_friendly}]
    <#else>
    <#assign stoploop=true> 
    </#if>
    <#else>
    <a href="${message.view_href}">${message.subject}</a>&nbsp;[${message.post_time?datetime?string}]
    </#if>
    </#list>
    <ul>
    
    <#if stoploop==true> <#break> </#if>
    </#list>

     

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    OlivierS  Unfortunately lithium don't support API V2 for notification and also have capability for  page size only 1000. you used offset in API V2 it doesn't work for me.. Looking for other way to resolve. it..

  • Hi Gyz, I gota fix for that. It might not be upto standard but it fixed my issue. Following is the snippet which shows only used notification instead of unused notification. Once it will go up 1000+ it will assign allnotification to 999. It works perfectely for me.

     

    <#assign _notificationsCount = restadmin( '/users/id/' + user.id + '/notifications/count' ).value?number />
                    <#if ( _notificationsCount > 999 )>    
                    <#assign _notificationsCount = 999 />
                    </#if>

     

    Note: Solution as per my requriement.