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

Add total contribution counts #552

Closed
3 tasks
teolemon opened this issue Sep 8, 2022 · 5 comments
Closed
3 tasks

Add total contribution counts #552

teolemon opened this issue Sep 8, 2022 · 5 comments

Comments

@teolemon
Copy link
Member

teolemon commented Sep 8, 2022

@teolemon teolemon added the 🏄‍♀️ good first issue Good for newcomers label Sep 8, 2022
@M123-dev M123-dev changed the title Add total contribution counts Grace Hopper - Add total contribution counts Sep 8, 2022
@monsieurtanuki
Copy link
Contributor

That still doesn't solve the case where the user logged in with an email instead of a user name :(

@M123-dev
Copy link
Member

Fyk @monsieurtanuki just created #7361

@teolemon teolemon changed the title Grace Hopper - Add total contribution counts Add total contribution counts Sep 28, 2022
@teolemon
Copy link
Member Author

@monsieurtanuki monsieurtanuki self-assigned this Oct 10, 2022
@monsieurtanuki
Copy link
Contributor

Actually we don't need an additional method; we can already get the count:

    /// Returns the number of contributions of a [type] by a [userId].
    Future<int?> _getMyCount(
      final String userId,
      final UserProductSearchType type,
      final OpenFoodFactsLanguage language,
    ) async {
      final UserProductSearchQueryConfiguration configuration =
          UserProductSearchQueryConfiguration(
        type: type,
        userId: userId,
        pageSize: 1,
        language: language,
        fields: [],
      );

      final SearchResult result;
      try {
        result = await OpenFoodAPIClient.searchProducts(
          OpenFoodAPIConfiguration.globalUser,
          configuration,
          queryType: OpenFoodAPIConfiguration.globalQueryType,
        );
      } catch (e) {
        return null;
      }
      return result.count;
    }

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

4 participants