Hello community!


So, I'm developping an app that it works like a forum where you cant post content and then make comments about it, I did the comment's logic using a web block because ill have a comments field on two distinct places (category view & posts).

Ideally, when you enter the screen it's displayed the recent comments and if the number of comments is > 5 it will display a ''see more'' button. For that I think is important to have the count of the total number of comments and also the number of how many are being displayed something like '' 5 comments out of 50 total "

My "see more" behaviour is working just fine but I think because of that i messed up with the line count and i cant display the correct values on the counting

Is it not the pagination itself which can be extended as "see more" thing?

Hi Ana,

The most performant way is to create a seperate Aggregate or SQL that is as simple and fast as possible (so no left joins or unnecessary inner joins), for counting the number of records.

Hi Ana,

the reason you are displaying the wrong number is that you are using length (# records currently in list) instead of count ( # records in database that fit query).



good luck,

Dorine

@Dorine: Note that using the "Count" property forces the Platform to create a hidden second query, that's identical to the first, but having a count as output. This can be a lot slower than creating a good count query oneself.

Really ?  Thanks for the tip.

Ana Santos wrote:

Hello community!


So, I'm developping an app that it works like a forum where you cant post content and then make comments about it, I did the comment's logic using a web block because ill have a comments field on two distinct places (category view & posts).

Ideally, when you enter the screen it's displayed the recent comments and if the number of comments is > 5 it will display a ''see more'' button. For that I think is important to have the count of the total number of comments and also the number of how many are being displayed something like '' 5 comments out of 50 total "

My "see more" behaviour is working just fine but I think because of that i messed up with the line count and i cant display the correct values on the counting

Hi Ana,

Please find the attached updated OML file, i have fixed issue that you are facing.

I think it can help :)

https://vermaamit52.outsystemscloud.com/Web/Categories_List.aspx?(Not.Licensed.For.Production)=

Thanks,

AV


Kilian Hekhuis wrote:

Hi Ana,

The most performant way is to create a seperate Aggregate or SQL that is as simple and fast as possible (so no left joins or unnecessary inner joins), for counting the number of records.


An aggregate on the web block's preparation? 

Amit Verma wrote:

Ana Santos wrote:

Hello community!


So, I'm developping an app that it works like a forum where you cant post content and then make comments about it, I did the comment's logic using a web block because ill have a comments field on two distinct places (category view & posts).

Ideally, when you enter the screen it's displayed the recent comments and if the number of comments is > 5 it will display a ''see more'' button. For that I think is important to have the count of the total number of comments and also the number of how many are being displayed something like '' 5 comments out of 50 total "

My "see more" behaviour is working just fine but I think because of that i messed up with the line count and i cant display the correct values on the counting

Hi Ana,

Please find the attached updated OML file, i have fixed issue that you are facing.

I think it can help :)

https://vermaamit52.outsystemscloud.com/Web/Categories_List.aspx?(Not.Licensed.For.Production)=

Thanks,

AV



Yes this worked for the total but still since i've this variable showcount with the value 5 ( it ads 5 more records on the line count on the screen when you click " see more comments") the value that appears is always a multiple of 5 and it doesn't correspond to the actual rows displayed !
Thanks for using your time to help me  ! I'll try to fix the rest but you were very helpfull.
br

Ana Santos wrote:

An aggregate on the web block's preparation? 

An aggregate at the same location as the main query fetching the records.


Kilian Hekhuis wrote:

Ana Santos wrote:

An aggregate on the web block's preparation? 

An aggregate at the same location as the main query fetching the records.


I'm sorry but I can't understand. 

Probably I should have said this before starting making questions, but my programming knowledge it's a bit low since im a designer so i think I'm not getting it bcs i don't understand the context or how it would work. 


Hi Ana,

If you're a designer, then why are you asking developer questions on a (mostly) developer forum? :). I don't know how to explain it better, unfortunately (or at least not without a considerable investement in time).

Kilian Hekhuis wrote:

Hi Ana,

If you're a designer, then why are you asking developer questions on a (mostly) developer forum? :). I don't know how to explain it better, unfortunately (or at least not without a considerable investement in time).

Ahm, maybe I'm learning outsystems so I can become a dev? What do you mean by why I'm asking developer questions on a dev forum? If I've a doubt about something that dev probably knows i think that means this is the right place to put my question even tho I'm depending on the goodwill of the community to "invest" their time on my problem but i don't have another option because I'm kinda learning everything all by myself with the tutorials.

Either way, I just wanted to explain that maybe I was not understanding what you're saying due to some lack of programming skills or something like that. 

But thanks Kilian for investing that time on making me reflect why i was making that question

br

Dorine Boudry wrote:

Hi Ana,

the reason you are displaying the wrong number is that you are using length (# records currently in list) instead of count ( # records in database that fit query).



good luck,

Dorine

Thanks! 

You're right i was using lenght and that was wrong, now showing the real value!


Hi Ana,

I understood your reply as meaning you're not a developer, nor want to be one, but you're a designer trying to code for some reason. I did not mean to offend you in any way.


Kilian Hekhuis wrote:

Hi Ana,

I understood your reply as meaning you're not a developer, nor want to be one, but you're a designer trying to code for some reason. I did not mean to offend you in any way.



It's ok, im not offended. Just explained myself :p
Thanks again Kilian!

Solution

Hi Ana,

Looked into your code and did a couple of changes and that widget is working as it should. Look into it and let me know if you have any doubt. I did for CategoryId you need to do for PostId

1 - Merged your 2 aggregates into 1 or it will never work as you want

2 - Add other aggregate to have a count in a separate aggregate that don't contains inner joins

3 - Changed the way you show the show more and the number of records showing

4 -  forced your aggregate to only return the records that you are showing on screen with max record property. because of this I refresh the aggregate when you click show more.

Regards,

Marcelo

Solution

Marcelo Ferreira wrote:

Hi Ana,

Looked into your code and did a couple of changes and that widget is working as it should. Look into it and let me know if you have any doubt. I did for CategoryId you need to do for PostId

1 - Merged your 2 aggregates into 1 or it will never work as you want

2 - Add other aggregate to have a count in a separate aggregate that don't contains inner joins

3 - Changed the way you show the show more and the number of records showing

4 -  forced your aggregate to only return the records that you are showing on screen with max record property. because of this I refresh the aggregate when you click show more.

Regards,

Marcelo

Hi Marcelo! 


Thanks for looking into my code. I looked to all the changes you did, wrotte down the logic, and did them one by one on my oml for the category id . i'll try to repeat the exercise for the post but i've another question, i want to reuse the same webblock, in order to do make that happen i think i shoul  make an ''if'' on the WB preparation to identify what ''logic'' it will ''render'' or should i just make another component without reusing the comments WB? 


Hi Ana,

Of course having everything on the same webblock without repeating code is better but is more complex to do. For now I recommend you to go always for the simplest solution even if it's not the perfect solution.

But for example in this case you only needed to change the filter to this 

SyntaxEditor Code Snippet

If(PostID = NullIdentifier(),Comments.CategoryId = CategoryId, Comments.PostId = PostID)

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Ana,

Of course having everything on the same webblock without repeating code is better but is more complex to do. For now I recommend you to go always for the simplest solution even if it's not the perfect solution.

But for example in this case you only needed to change the filter to this 

SyntaxEditor Code Snippet

If(PostID = NullIdentifier(),Comments.CategoryId = CategoryId, Comments.PostId = PostID)

Regards,

Marcelo

Let me see if i got it 

Ok. If my postid its null means that i'm not on a post screen,  so comments.categoryid = categoryID, otherwise ill be on a post screen and PostID will be the same as comments.post id
That is much straight forward than what i was going for ! Thanks Marcelo!


BR



You got it.

Happy coding