Modify multiple users data with specific conditions

(One) Question table
(Many) Question Action History table
(Many) Users

One to many relationship, 10 users voted UP for the question on the history table and only 3 voted down.

I want to reward the users who got consensus correct by adding them credit points. How can I do it? My head went spinning on how loop over the records.

How I tried to do it:
Change a list of things:
Search for all users credit_points = current_credit_points +1
Only If search question history table where vote=up

Kind help needed.

My 2 cents for bubble owners… do not hire any marketers, hire bubble developers who respond to user inquiries. If many knew about bubble but no one was able to use it… good luck.

A very similar platform to bubble is Filemaker and their documentation is great and their platform is older and they have lots of advanced material on lynda.com unfortunately though they’re not web optimized from the ground up.

That one needs a bit of thought @arto.eg and I’m not sure too many of us are diving deep on a Sunday afternoon … I’ll give it some thought a bit later but you suggested approach does sound like the way to go.

You might also want to think about the Do a Search : filtered functionality and the Do a Search : grouped by functionality. One or the other might make shortlisting those who will a credit point easier and faster.

My App Link:
https://sa7elsa7.bubbleapps.io/version-test?debug_mode=true

What I am trying to edit in the workflow is for this button:

Whenever you need to iterate over a list of things, you have several options including:

  1. Do an API workflow on a list of things.
  2. Workflow action > Make Changes to a List of Things (done in a workflow on a page)
  3. Workflow action > Make Changes to a List of Things (done in an API workflow or scheduled workflow)

In your case, I’m guessing #3 is what you’re looking for. But in terms of designing and testing your solution, you can futz around with it in an on-page workflow.

Here’s an example of what “Make Changes to a List of Things” can do:

I just created this in my own app. My Users do not have a “points” or “credits” or whatnot, so I just created this field called “Points (Temp)” by way of example.

As you can see, all you have to do is come up with a search that is constrained/filtered/etc. for the “List to change” and you can easily “add a point” to all users that meet that criteria.

In your case, you seem to have some sort of time-limited question. During the time period, Users can up or downvote on the question. At the end of the time period, you check upvotes vs downvotes. If count of upvotes > count of downvotes, apparently “upvotes” is the “winner”. Otherwise, “downvotes” is the “winner.”

Knowing that, all your search needs to do is: Find the Users who did the right thing and give them a point by executing something like the workflow step in my screenshot above.

That should be enough to get you started!

Thanks Keith, the problem I am facing is because the history of the user votes is in another table called QWorkActionHistory where I need to get the info from there and then compare it with the variable in the Question table which concluded which votes win QStatus=ProfPass. If it was all in the same table it would be easy.

So if QWorkHistory ProfVot=Yes for All Users
&
Qstatus =ProfPass for that particular question

Then give credit points to all related Users. And I have created the relationships in my database.

Once the application I am trying to build works, I believe it will make a difference in the world. I am building a Q&A app with 99% community moderation, I will describe the whole business logic in details once I finish the main moderation modules and Q&A functionality. I want my idea to be expressed practically because that is what Bubble initially intends in its philosophy, to ENABLE non coders to put their idea into action for the first time in history (not exactly the first, but for individuals it probably is).

Might I suggest that you are over complicating things?

The votes on a question should be a property of the Question object. Have a list of “Vote”s on object Question. Vote data type should have at least one fields — Vote (type Boolean, which bubble calls “yes/no”). You might also want a field for Question but it’s not 100% clear that’s required here. You will note that Vote does not need a field for “User”. Why? Because the User in question will be the Vote’s “Creator”! (Neat, eh?)

When a user votes on a question do Create a new thing… of type Vote… with Vote = whatever they voted. Then: Make changes to a thing… Question (the Question in question)… Votes add list (the Vote you just created).

(In short: create a vote. Attach the vote to the question.)

In that way you would know which users voted (and in what way) on the Question.

If you’re looking for someone to fix your app in context, you’ll have to share your editor. There are a hundred ways to skin this particular cat and it’s unlikely that the way you’ve organized things would preclude you from doing what you want.

But this is an EASY - like, super easy - thing if you organize the data in the right way.

When there’s an easier way, don’t get hung up on your current data model. Just change how you do things. Bubble is amazingly forgiving in this way.

If you’re having trouble working it out in your current schema, create a blank page and drop a Repeating Group on it. What you’re trying to do is come up with the search criteria for that group to display the right list of users who won your question. (And hence need their scores changed.). Once you come up with that, you’re golden, right?

Do that.

2 Likes

This is a very obtuse and unbubble way to approach the problem.

Please see my previous reply for a far simpler way to approach this.

But let’s break it down:

Can you get a list of users who voted on a particular question in your current data model? (And can u tell how individual users in that list voted on that question?) if yes, you are good. If no, proceed.

Can you get a list of users who voted a certain way on a certain question in your current data model? If yes, you are good. If no, you need to go back to the drawing board.

It’s really that simple.

1 Like

Hi Arto,

Do you really need the table Question Action History?

Consider adding two fields of type “list of users” to your Question table. One field is called Upvoters and one field is called Downvoters.

When each user votes on a Question add that user to the Question’s appropriate “list of users” … Upvoters or Down voters.

When the Question response period ends, get the Question’s Upvoter’s:count and the Question’s Downvoters:count.

When Upvoter’s:count > Downvoter’s:count:
Make changes to a list of user’s… Question’s Upvoter’s. Current credit points add 1.

When Downvoter’s:count > Upvoter’s:count:
Make changes to a list of user’s… Question’s Downvoter’s. Current credit points add 1.

Does that make sense?

If you share access to your editor, we could take a look and it might be easier to understand the proposed solutions.

Nathan

2 Likes

Thank you all for your contributions it is really helping and yes my database structure is messy hence the very slow performance.

I’ve received the same advice from several experienced users so far and I’m going to change the database structure. I have copied the whole app and will apply the changes on the new one today.

I’ll let you know what I did and if the suggestions worked. Thanks a lot.

1 Like

After implementing the new database structure there seems to be enormous speed difference, now the work flow of my web app is much faster.

Notes:

  1. Do A Search For inside >> Only When gives a lot of delay in web page processing. So I removed these conditions while I can, and I am not sure why it’s recommended.

  2. I stumbled upon a very odd bubble behavior. I was trying to do a calculation on the Remaining Votes field in Questions Table, so I had to set:

RemaningVotes = 11 - VoteCount

But the problem that bubble will not allow me to do that, and one of the experienced users suggested me to put an invisible input element on the page with number 11 so I can use it as a work around. Is this really guys how we should do things on bubble or this is another clear bug? Look at the screenshot for reference:

image

Notice… strangely enough the opposite was possible but it would give me the resulted number in the negative!

image

Here’s a clue why …

The problem with number fields, entering a static number turns the expression into static and prevents dynamic expressions. So you need to start with a dynamic expression that returns a number. This can get it to work, but is hard to understand later if the expression isn’t related to the calculation.

You could do, for example,

RemainingVotes = VoteCount - VoteCount - VoteCount + 11

When you maintain this later you’d say “What does this even mean?” haha

1 Like

Thanks for the tip mishav, I used your solution at first then made a workaround that I am more pleased with. Which is to create a new field in my Users table called MaxVotePower = 11, then I can easily use it as a constant whenever I wish. This will also give me the flexibility to not modify every single workflow whenever I make changes to the max vote power. All I will have to do later is to just modify the field.

So to recap:
RemainingVotes = MaxVotePower - VoteCount

Nice solution! You can have it a different value for each user.

Or create a new table for system-wide constants if you want it centralised : )
(Edit) Additional small performance hit for the lookup … drats.

(Edit 2) Sometimes I find the need for both a centralised default, and a localised optional override.

1 Like

Nice Idea @mishav I do that now for variable values and for HTML icons I reuse regularly in the app. But I load them initially into hidden elements so I simply refer to the element instead of having the performance hit every time.

Of course, I have a performance hit initially but in an SPA I will have that anyway so I have a little GIF while loading to entertain. If @arto.eg is calling his constriants for API workflows then the hit will not matter.

1 Like