Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting projects in dropdown based on recent activity not alphabetically #350

Open
alexanderjeurissen opened this issue Sep 11, 2015 · 8 comments

Comments

@alexanderjeurissen
Copy link

Often I find myself working on a limited set of projects at any given time, I think it would speed up the time tracking process if the projects I recently created entries for are on top in the dropdown.

An alternative would be to sort the projects in the dropdown based on recent activity of the tenant as a whole. That way less active projects would be on the bottom of the dropdown list.

@jurre
Copy link
Contributor

jurre commented Sep 11, 2015

Yes, I agree :)

@alexanderjeurissen
Copy link
Author

which of the two would seem more logical to you @jurre ? (based on recent activity of the user, or based on recent activity of the tenant as a whole )

@jurre
Copy link
Contributor

jurre commented Sep 11, 2015

Either is an improvement, I think the users activity would probably be more relevant for this though

@jnillo
Copy link

jnillo commented Sep 18, 2015

HI guys,

I think that a possible solution is update the project (update the updated_at field only) after create a new entry. In this way, we only list the projects order by updated_at field. In other case, we need sort them by the last entry and we need to make a lot of queries and check all creation dates.

If you want (/cc @jurre @alexanderjeurissen ), I can change after save callback in entries to update the project field (updated_at). If you have any other possible solution I can do it too.

@jurre
Copy link
Contributor

jurre commented Sep 18, 2015

You could just do

belongs_to :project, touch: true

Right?

@alexanderjeurissen
Copy link
Author

@jurre the entry model already has

belongs_to :project, touch: true

Only sorting the project list that is rendered is necessary, however that would result in sorting the projects based on activity of the whole tenant. creating the desired behaviour for just the current user is a bit more complex.

@alexanderjeurissen
Copy link
Author

I just checked and the Project model already has a scope named by_last_updated so changing the relevant line in https://github.com/DefactoSoftware/Hours/blob/development/app/views/application/_entry_form.html.haml#L5 to use that scope instead of by_name will result in the sorting based on project activity of the whole tenant.

@jnillo
Copy link

jnillo commented Sep 18, 2015

Yes, it's a possibility. You need consider what is a "update for the project" in order with the project philosophy. Of course if you update the name of the project you update the project but this action meaning that it's an active project in that moment? I mean that we need take a decision if we add a new field to manage the last real update of the project (new entry or other event) or an update the updated_at field is enough. In the first case, we need to create callback to update the new field in project model when a relevant success appear, for example, after create in Entry model will update this new field in his project. In the second case, only with the modification of @alexanderjeurissen is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants