Page 1 of 3

displaying completed tasks by user

Posted: Thu Feb 27, 2014 8:19 pm
by Shawn Johnson

Hello,

I having some trouble understanding how to complete this task.

I have task being created in appery database from web interface similar to the todo list example.

I need to be able to list the all the tasks a given user has completed over a given period of time, like a week.

I also need to list all the users who have completed a task sorted by the user with the most points (a leaderboard)

here is the flow:
admin creates task, each tasks has points associated with them
users login and select the task they have completed.
users can see the task they have completed over the last week
users can see the all the tasks completed by all users

I would appreciate some help getting this feature completed, I am pretty close I have tasks in the database, I have user logins and user registeration

I am just not clear how to update the tasks with the user ids who have completed them.
and how to list only completed tasks the logged in user has completed

Thanks


displaying completed tasks by user

Posted: Thu Feb 27, 2014 8:58 pm
by Illya Stepanov

Hello -

You need to use parameter where:
http://docs.appery.io/documentation/b...


displaying completed tasks by user

Posted: Thu Feb 27, 2014 9:39 pm
by Shawn Johnson

Thanks lllyan,

can you tell me how i add multiple items in there where clause?


displaying completed tasks by user

Posted: Thu Feb 27, 2014 10:05 pm
by Illya Stepanov

You can use code$and/code here is MongoDB reference: http://docs.mongodb.org/manual/refere...


displaying completed tasks by user

Posted: Sat Mar 01, 2014 9:50 am
by Shawn Johnson

Thanks for that update. I am still having some issues.
now i can list items that are completed vs not completed. but I need to understand how i can make this work for multiple users.

so if i have user complete a task the task should still be available for other users who have not complete the task yet, can someone point me in the right direction how to do that.

I need to be able to have a task with multiple userid's for those who have completed them. I need to be create view that list those who have completed the task.

any help would be appreciated.


displaying completed tasks by user

Posted: Mon Mar 03, 2014 5:06 am
by Igor

Let's make user-tasks(multiple to multiple) implementation example:

1 Create user collection.

2 Create task collection.

3 Create user_task collection(which associate users and tasks) with three columns:

3.1 user(pointer to user collection)

3.2 task(pointer to task collection)

3.3 complete(define state of task for user)

4 Create_new-DataBase_services-your_db-user_task-query and click "Import selected services"

5 Navigate to this service in "Test" tab

1 Get all user_task for user with id="52fe1b6fe4b0a25c11c899e0"

pre
code
{user: {"$inQuery": {_id: "52fe1b6fe4b0a25c11c899e0" } } }
/code
/pre

2 Get all user_task where user_name = "Ben"
pre
code
{user: {"$inQuery": {user_name: "Ben" } } }
</pre>
/code
3 Get all user_task where task_id = "52fdd8a9e4b07b0d80136249"
pre
code
{task: {"$inQuery": {id: "52fdd8a9e4b07b0d80136249" } } }
/code
/pre
4 Get all user_task where user_id = "52fe1b6fe4b0a25c11c899e0" and where task_id = "52fdd8a9e4b07b0d80136249"
code
<pre>
{ "$and": [ {user: {"$inQuery": {id: "52fe1b6fe4b0a25c11c899e0" } } }, {task: {"$inQuery": {_id: "52fdd8a9e4b07b0d80136249" } } } ] }
/code
/pre

5 Get all completed user_task where user_id = "52fe1b6fe4b0a25c11c899e0"
pre
code
{ "$and": [ {user: {"$inQuery": {_id: "52fe1b6fe4b0a25c11c899e0" } } }, {complete: true} ] }
/code
/pre

6 Get all completed user_task where task_id = "52fdd8a9e4b07b0d80136249"

pre
code
{ "$and": [ {task: {"$inQuery": {_id: "52fdd8a9e4b07b0d80136249" } } }, {complete: true} ] }
/code
/pre

This doc should be helpful: http://docs.appery.io/documentation/b...


displaying completed tasks by user

Posted: Mon Mar 03, 2014 5:14 am
by Shawn Johnson

Thank you for the very well laid and clear answer.

few questions

for 3-3.3

how do i make the items pointers to another collection?

-shanw.J


displaying completed tasks by user

Posted: Mon Mar 03, 2014 5:20 am
by Igor

You need to create column with type "pointer" http://docs.appery.io/documentation/b...


displaying completed tasks by user

Posted: Mon Mar 03, 2014 11:49 pm
by Shawn Johnson

hello,

thanks for helping me, I think i may be confused
i have create the collection with the two pointers
3.1 user(pointer to user collection)

3.2 task(pointer to task collection)

3.3 complete(define state of task for user)

but my question is am i am supposed to populate the collection, I am trying update the table with the user id and task id but i can't seem to update them collection . sorry for all the questions i am just not clear, I manually enter a value and when i use the where clause you provided i get results but not without.

-Shawn.J


displaying completed tasks by user

Posted: Tue Mar 04, 2014 1:35 am
by Illya Stepanov

Hi Shawn,

Try to populate collections with: https://appery.io/database/ interface.

Please follow by:
ol
liyou should populate "user" collection by your values./li
liyou should populate "task" collection by your values./li
liyou should populate "user_task" by:/li
ol
liuser - by real "id" from "user"(1) collection./li
litask - by real "id" from "task"(2) collection./li
/ol
/ol
After these steps you have to test your "where" clause with real "_id" from "user" and "task" collections.