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

Improve the accuracy of the filter card_V1 —— publication date(materials Page) #56

Open
SeverusYixin opened this issue Nov 14, 2024 · 1 comment · May be fixed by #62
Open

Improve the accuracy of the filter card_V1 —— publication date(materials Page) #56

SeverusYixin opened this issue Nov 14, 2024 · 1 comment · May be fixed by #62
Labels
Priority 3 ergonomic maturity level

Comments

@SeverusYixin
Copy link
Collaborator

The accuracy issue with the filter cards: the number displayed in the top right corner does not match the actual count.

@SeverusYixin SeverusYixin added the Priority 3 ergonomic maturity level label Nov 14, 2024
@SeverusYixin SeverusYixin changed the title Improve the accuracy of the filter card —— publication date Improve the accuracy of the filter card —— publication date(materials Page) Nov 14, 2024
@SeverusYixin SeverusYixin changed the title Improve the accuracy of the filter card —— publication date(materials Page) Improve the accuracy of the filter card_V1 —— publication date(materials Page) Nov 14, 2024
@SeverusYixin
Copy link
Collaborator Author

SeverusYixin commented Nov 18, 2024

Possible :the difference definition of here:

1.In search result page:

        if (source.publication_date) {
          const year = source.publication_date.toString().split('-')[0];
          publicationDates[year] = (publicationDates[year] || 0) + 1;
        }
  1. In materials page:

    if (item.publication_date) {
    let year;
    if (typeof item.publication_date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.publication_date)) {
    year = parseInt(item.publication_date.split('-')[0], 10);
    } else if (typeof item.publication_date === 'string' && /^\d{4}$/.test(item.publication_date)) {
    year = parseInt(item.publication_date, 10);
    } else if (typeof item.publication_date === 'number') {
    year = item.publication_date; // If the year is provided as a number
    }

     if (year && year >= 1900 && year <= new Date().getFullYear()) {
       publicationDates[year] = (publicationDates[year] || 0) + 1;
       minYear = Math.min(minYear, year);
       maxYear = Math.max(maxYear, year);
     }
    

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 3 ergonomic maturity level
Projects
None yet
1 participant