I have a lists with active tasks and want to build a dashboard, where the user can see what tasks are still not completed. Sadly it is a task that multiple users are assigned to. How to query it?
I don’t like the idea of query on the whole database to get all active tasks and then to take it apart, to find the right assigned to that user.
With few hundreds of tasks it will take some time to check everything and the dashboard load at the start of the application. It would take too much time. With Async from Anvil Extras I could maybe trick the loading time, but such effort to get like 1-20 rows of data?
anvil.tables.TableError: Column 'assigned_users' can only be searched with a List of rows from 'Users' table (not a Row from 'Users' table) in table 'task_manager'
@anvil.server.callable
def get_tasks_active_data():
"""popalte dashboard with tasks"""
user = anvil.users.get_user()
data = app_tables.task_manager.search(q.fetch_only('task_id', 'status', 'next_qs_action', 'deadline', 'completed_objects', 'total_objects'),
tables.order_by('creation_date', ascending=True),
assigned_users=user,
status=q.none_of('Completed', 'Quality assurance'))
return data
You might want to post a clone link with a minimal example showing the issue, then, so people can play with it. Simply saying that something doesn’t work doesn’t give us enough information to be able to help.
Sorry it was my mistake by typing on phone. I did it before with*. I just haven’t mentioned it. It gave me the same error.
``anvil.tables.TableError: Column ‘assigned_users’ can only be searched with a List of rows from ‘Users’ table (not a Row from ‘Users’ table) in table ‘task_manager’```
I found a solution. Expanding the list with * was wrong. Syntax was a list of rows not an expanded list.
@anvil.server.callable
def get_tasks_active_data():
"""popalte dashboard with tasks"""
user = [anvil.users.get_user()]
#don't expand the list with '*'
data = app_tables.task_manager.search(q.fetch_only('task_id', 'status', 'next_qs_action', 'deadline', 'completed_objects', 'total_objects'),
tables.order_by('creation_date', ascending=True),
assigned_users=q.any_of(user),
status=q.none_of('Completed', 'Quality assurance'))
return data