Skip to content

In depictions selection screen, suggest recently selected items #3634

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

Closed
nicolas-raoul opened this issue Apr 9, 2020 · 28 comments · Fixed by #4361
Closed

In depictions selection screen, suggest recently selected items #3634

nicolas-raoul opened this issue Apr 9, 2020 · 28 comments · Fixed by #4361

Comments

@nicolas-raoul
Copy link
Member

For now, the depictions selection screen does not show anything when no search string is entered.
Instead, it would be good if it could suggest:

  • Items that were selected during previous uploads.

This feature exists in the category selection activity, so that activity can be studied for inspiration.

@johnnyrev
Copy link

Can it be assigned to me?

@johnnyrev
Copy link

If I get it straight, this is for step 2 of "upload" search. If so, you want the items shown with checkboxes, as they are in step 3, or with their depictions and descriptions?

@nicolas-raoul
Copy link
Member Author

Yes, this screen:
Screenshot_20200411-183347_Commons
It should show for instance the last 10 chosen items. If possible implement like done in categories, for consistency. Thanks!

@macgills
Copy link
Contributor

This functionality has been broken for contributions since 13/06/19, partially fixed in #3650

If somebody could tell me what

    private boolean hasDirectCategories() {
        return !directKvStore.getString("Category", "").equals("");
    }

a "direct category" is then that would help, as far as I can tell nobody ever writes anything to this preference. @maskaravivek

@johnnyrev a new Room Dao will have to be added so that when a user selects a depiction we save that to the database. When search term is empty we, if following the example of category model, would take the 25 most recently selected from the database to show them in a list.

There is however a lingering question of precedence for me, do we show items from nearby locations first here or recently selected items first. @nicolas-raoul

@nicolas-raoul
Copy link
Member Author

My guess would be that "direct" was related to campaigns, and thus can be removed as the campaigns feature was removed years ago.

I would put nearby items before recent items.

@macgills
Copy link
Contributor

@nicolas-raoul apologies for going off topic here but campaigns have been removed?

image

This is only on beta but it looks like the feature is still very much there. Can we remove it? @misaochan

@nicolas-raoul
Copy link
Member Author

nicolas-raoul commented Apr 21, 2020 via email

@macgills
Copy link
Contributor

Thanks for the info @nicolas-raoul

@johnnyrev are you still working on this? I have availability as I think I have already commented on another of your tickets

@johnnyrev
Copy link

@macgills Actually me and @dafnith have started working on that and we want to totally reproduce it. Thanks for asking, but we can’t give it away!

@sivaraam
Copy link
Member

@johnnyrev It's good to know that you and @dafnith are working on this. I just wanted to let you know that in case you feel stuck somewhere, feel free to ask for help here :)

@johnnyrev
Copy link

@sivaraam Thanks a lot, we appreciate it!

@dafnith
Copy link

dafnith commented May 17, 2020

It seems that in the category selection screen does not show anything when no search string is entered. It shows a red message that there are no results. I tried to upload a picture multiple times and somehow it worked. When I tried again the red message appeared again. Is this normal?

I am also wondering what do you mean by "Items that were selected during previous uploads."
Previous uploads of the current user or just the uploads that have been made in general?

@nicolas-raoul
Copy link
Member Author

@dafnith We merged Structured Commons work into the master branch and fixed a few bugs. Please git pull, git switch master, rebuild and test again, if you still see the red message please post a screenshot here. "previous uploads" refers to the images that the user has recently uploaded. I encourage you to check the category selection screen and see how it works :-)

@dafnith
Copy link

dafnith commented May 19, 2020

@nicolas-raoul Thank you for your response!
As for the implementation we are thinking of creating the Room Dao that @macgills mentioned and name it DepictionsDAO.java. We are going to follow the steps in which CategoriesDAO is made.
If our way is correct then in which branch we are supposed to write the code?

@nicolas-raoul
Copy link
Member Author

@dafnith Please create a new branch (named for instance 3634-suggest-recently-selected-items) on the latest master. Thanks!

@dafnith
Copy link

dafnith commented May 19, 2020

@nicolas-raoul Thank you!
I would also be happy if you could explain the purpose of the structured-data branch and when should I switch at it thought..

@macgills
Copy link
Contributor

Structured data was a branch where Depictions(multilingual captions/descriptions) were implemented, it has been merged to master for a good few weeks now

@nicolas-raoul nicolas-raoul changed the title [structured-data branch] In depictions selection screen, suggest recently selected items In depictions selection screen, suggest recently selected items May 19, 2020
@dafnith
Copy link

dafnith commented Jun 13, 2020

@sivaraam we actually got stuck trying to save the selected depictions in the database. Our method that inserts recent depictions in recent_depictions table uses a list with RecentDepictions objects.

  public Single<List<Long>> save(List<RecentDepictions> recentDepictions) {
    return localDataSource.saveRecentDepictions(recentDepictions);
  }

We want to call this method from UploadModel.java file but we don't know how to convert the DepictedItem object to RecentDepictions object

    public void onDepictItemClicked(DepictedItem depictedItem) {
        if (depictedItem.isSelected()) {
            selectedDepictions.add(depictedItem);
        } else {
            selectedDepictions.remove(depictedItem);
        }
    }

@sivaraam
Copy link
Member

I think you should be persisting the DepictedItem objects of the recently used depictions rather than creating a new class `RecentDepictions. You could see this being done for Categories too.

From CategoriesModel.kt:

    fun updateCategoryCount(item: CategoryItem) {
        var category = categoryDao.find(item.name)

        // Newly used category...
        if (category == null) {
            category = Category(null, item.name, Date(), 0)
        }
        category.incTimesUsed()
        categoryDao.save(category) // Note how the Category object itself is saved here
    }

Others could comment better about this.

PS: You're more likely to get a faster response when you don't ping specific people :)

@macgills
Copy link
Contributor

We specifically don't want to use DepictedItems. It is generally good practice to have separate models for different domains of your application and this illustrates that well.

Were we to save DepictedItems, if we follow the example of Category, we would need to add

    private Date lastUsed;

to the DepictedItems and this would pollute that class as these fields only matter in the database layer of our application, ie nobody else cares about lastUsed. a reasonable way to approach this problem is composition

data class RecentDepictedItem(item:DepictedItem, lastUsed:Date)

Category is all around a really bad example, unused fields, legacy contentProvider associated and its name is misleading as unfortunately we don't Type our categories and instead just use Strings when we get them from the API. This problem is likely because of this class stealing the namespace of Category from the application whereas were it RecentCategory it would be far more accurately named and not make this sentence heavily confusing when I switch from talking about a Category to the categories

@johnnyrev
Copy link

Excuse me for this delayed comment, but due to some problems with the implementation process and the restricted time that we have this period of time, me and @dafnith aren't able to keep up with this issue. So, feel free to assign this issue to someone who is able to spend more time and get this thing done.

By the way thanks for all the information and help that you gave us. It was a very good experience working with you!

Our excuses again!

@sivaraam
Copy link
Member

@johnnyrev Ok. Thanks for letting us know.

@sivaraam sivaraam removed the assigned label Jul 14, 2020
@neslihanturan
Copy link
Collaborator

Anyone who is interested with this issue, please make sure you followed previously opened PR #3771

@Prince-kushwaha
Copy link
Contributor

Prince-kushwaha commented Apr 14, 2021

@nicolas-raoul @neslihanturan i want to work on this issue

@nicolas-raoul
Copy link
Member Author

@Prince-kushwaha It is yours, thanks!

@Prince-kushwaha
Copy link
Contributor

Prince-kushwaha commented Apr 16, 2021

@nicolas-raoul how many max number of recent depicts Selected item i save in Room database

@nicolas-raoul
Copy link
Member Author

10 should be good. Thanks!

@Prince-kushwaha
Copy link
Contributor

in room database how delete all element except first 10 element

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