Skip to content

Commit

Permalink
Add recent release sort option to the website (#256)
Browse files Browse the repository at this point in the history
In this commit, we add the release sort option to the frontend so the plugins can ranking by the latest released date.

---------
Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
  • Loading branch information
AhmedBasem20 authored Aug 17, 2023
1 parent 81f588b commit 106877f
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions aiida-registry-app/src/Components/MainIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const length = Object.keys(plugins).length;
const currentPath = import.meta.env.VITE_PR_PREVIEW_PATH || "/aiida-registry/";

function MainIndex() {
const [sortOption, setSortOption] = useState('commits');
const [sortOption, setSortOption] = useState('commits'); //Available options: 'commits', 'release', and 'alpha'.
const [sortedData, setSortedData] = useState(plugins);

useEffect(() => {
document.documentElement.style.scrollBehavior = 'auto';
setSortedData(sortByCommits(plugins));
handleSort(sortOption);
setupScrollBehavior();
}, [plugins, setSortedData]);
}, [sortOption]);

function sortByCommits(plugins) {
const pluginsArray = Object.entries(plugins);
Expand All @@ -35,6 +35,26 @@ function MainIndex() {
return Object.fromEntries(pluginsArray);
}

function sortByRelease(plugins) {
//Sort plugins by the recent release date, the newer the release date the larger the value,
//and the higher ranking it get. Sorting in descending order by date.
const pluginsArray = Object.entries(plugins);
pluginsArray.sort(([, pluginA], [, pluginB]) => {
if (!pluginA.metadata.release_date && !pluginB.metadata.release_date) {
return 0; // Both plugins have no release date, keep them in the current order
} else if (!pluginA.metadata.release_date) {
return 1; // Only pluginB has a release date, put pluginB higher ranking than pluginA.
} else if (!pluginB.metadata.release_date) {
return -1; // Only pluginA has a release date, put pluginA higher ranking than pluginB.
} else {
return new Date(pluginB.metadata.release_date) - new Date(pluginA.metadata.release_date);
}
});

//Return a new object with the sorted entries
return Object.fromEntries(pluginsArray);
}

function setupScrollBehavior() {
var prevScrollpos = window.scrollY;
window.onscroll = function() {
Expand All @@ -49,19 +69,21 @@ function MainIndex() {
prevScrollpos = currentScrollPos;
}
}
setupScrollBehavior();

const handleSort = (option) => {
setSortOption(option);


let sortedPlugins;
let sortedPlugins = {};
if (option === 'commits') {
sortedPlugins = sortByCommits(plugins);
}
else if (option == 'alpha') {
sortedPlugins = plugins;
}
else if (option == 'release') {
sortedPlugins = sortByRelease(plugins);
}

setSortedData(sortedPlugins);
};
Expand Down Expand Up @@ -100,6 +122,7 @@ function MainIndex() {
>
<MenuItem value='commits'>Commits Count</MenuItem>
<MenuItem value= 'alpha'>Alphabetical</MenuItem>
<MenuItem value='release'>Recent Release</MenuItem>
</Select>
</FormControl>
</Box>
Expand Down Expand Up @@ -129,6 +152,14 @@ function MainIndex() {
src={`https://img.shields.io/badge/Yearly%20Commits-${value.commits_count}-007ec6.svg`}
/>
}

{sortOption === 'release' && value.metadata.release_date &&
<img
className="svg-badge"
style={{padding:'3px'}}
src={`https://img.shields.io/badge/Recent%20Release-${value.metadata.release_date.replace(/-/g, '/')}-007ec6.svg`}
/>
}
</p>

<p>{value.metadata.description}</p>
Expand Down

1 comment on commit 106877f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issues in retrieved plugin metadata (ignore those for plugins not managed by you)

WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-QECpWorkChain]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-aenet]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-aenet]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-alloy]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-alloy]
WARNING! Entry point 'elastic' does not start with prefix 'alloy.' [aiida-alloy]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-autocas]
WARNING! No bdist_wheel available for PyPI release [aiida-bands-inspect]
WARNING! AiiDA version not found [aiida-bands-inspect]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-bigdft]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-castep]
WARNING! No bdist_wheel available for PyPI release [aiida-catmat]
WARNING! AiiDA version not found [aiida-catmat]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-catmat]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-catmat]
WARNING! Entry point 'vasp_base_parser' does not start with prefix 'catmat.' [aiida-catmat]
WARNING! Entry point 'vasp.base' does not start with prefix 'catmat.' [aiida-catmat]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-ce]
WARNING! No bdist_wheel available for PyPI release [aiida-champ]
WARNING! AiiDA version not found [aiida-champ]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! Entry point 'CHAMP' does not start with prefix 'champ.' [aiida-champ]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-core]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-crystal-dft]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-crystal17]
WARNING! Entry point 'potcar' does not start with prefix 'cusp.' [aiida-cusp]
WARNING! Development status in classifiers (alpha) does not match development_status in metadata (stable) [aiida-diff]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-diff]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-dynamic-workflows]
WARNING! AiiDA version not found [aiida-dynamic-workflows]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/environ-developers/aiida-environ/master/setup.json [aiida-environ]
WARNING! AiiDA version not found [aiida-environ]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-eon]
WARNING! AiiDA version not found [aiida-eon]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-eonclient]
WARNING! AiiDA version not found [aiida-eonclient]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/sphuber/aiida-fenics/master/setup.json [aiida-fenics]
WARNING! AiiDA version not found [aiida-fenics]
WARNING! AiiDA version not found [aiida-fireworks-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-fireworks-scheduler]
WARNING! Entry point 'fireworks' does not start with prefix 'fireworks_scheduler.' [aiida-fireworks-scheduler]
WARNING! Entry point 'fireworks-scheduler' does not start with prefix 'fireworks_scheduler.' [aiida-fireworks-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-fleur]
WARNING! Prefix 'gaussian' does not follow naming convention. [aiida-gaussian-datatypes]
WARNING! Unable to read wheel file from PyPI release: No entry_points.txt found in wheel [aiida-graphql]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-graphql]
WARNING! Entry point 'general-MD' does not start with prefix 'gromacs.' [aiida-gromacs]
WARNING! Entry point 'general-MD' does not start with prefix 'gromacs.' [aiida-gromacs]
WARNING! Unable to read wheel file from PyPI release: No entry_points.txt found in wheel [aiida-grouppathx]
WARNING! Development status in classifiers (alpha) does not match development_status in metadata (beta) [aiida-grouppathx]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-grouppathx]
WARNING! Entry point 'gpx' does not start with prefix 'grouppathx.' [aiida-grouppathx]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-gudhi]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-gudhi]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-gulp]
WARNING! No bdist_wheel available for PyPI release [aiida-kkr]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/JuDFTteam/aiida-kkr/develop/setup.json [aiida-kkr]
WARNING! AiiDA version not found [aiida-kkr]
WARNING! Development status in classifiers (beta) does not match development_status in metadata (stable) [aiida-kkr]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-kkr]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-lammps]
WARNING! Entry point 'dynaphopy' does not start with prefix 'lammps.' [aiida-lammps]
WARNING! Entry point 'dynaphopy' does not start with prefix 'lammps.' [aiida-lammps]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-lsmo]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-lsmo]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-metavo-scheduler]
WARNING! Entry point 'sshmetavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! Entry point 'pbsprometavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! Entry point 'sshmetavo' does not start with prefix 'metavo_scheduler.' [aiida-metavo-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-mpds]
WARNING! Entry point 'crystal.mpds' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! Entry point 'crystal.cif' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! Entry point 'crystal.aiida' does not start with prefix 'mpds.' [aiida-mpds]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/nanotech-empa/aiida-nanotech-empa/master/setup.json [aiida-nanotech-empa]
WARNING! AiiDA version not found [aiida-nanotech-empa]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-nanotech-empa]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/atztogo/aiida-nims-scheduler/master/setup.json [aiida-nims-scheduler]
WARNING! AiiDA version not found [aiida-nims-scheduler]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-nims-scheduler]
WARNING! Prefix 'quantumespresso.ocv' does not follow naming convention. [aiida-open_circuit_voltage]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-orca]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-phtools]
WARNING! No bdist_wheel available for PyPI release [aiida-porousmaterials]
WARNING! AiiDA version not found [aiida-porousmaterials]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-porousmaterials]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-psi4]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-python]
WARNING! AiiDA version not found [aiida-python]
WARNING! Prefix 'aiidapython' does not follow naming convention. [aiida-python]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-qeq]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-qeq]
WARNING! No bdist_wheel available for PyPI release [aiida-qp2]
WARNING! AiiDA version not found [aiida-qp2]
WARNING! Entry point 'noncollinearhydrogen' does not start with prefix 'quantumespresso.' [aiida-quantumespresso]
WARNING! Entry point 'spinorbithydrogen' does not start with prefix 'quantumespresso.' [aiida-quantumespresso]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-quantumespresso-hp]
WARNING! Prefix 'quantumespresso.hp' does not follow naming convention. [aiida-quantumespresso-hp]
WARNING! No bdist_wheel available for PyPI release [aiida-raspa]
WARNING! AiiDA version not found [aiida-raspa]
WARNING! Prefix 'core' does not follow naming convention. [aiida-shell]
WARNING! No bdist_wheel available for PyPI release [aiida-siesta]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.github.com/siesta-project/aiida_siesta_plugin/master/setup.json [aiida-siesta]
WARNING! No bdist_wheel available for PyPI release [aiida-spirit]
WARNING! AiiDA version not found [aiida-spirit]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-ssh2win]
WARNING! AiiDA version not found [aiida-ssh2win]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-sshonly]
WARNING! Entry point 'ssh_only' does not start with prefix 'sshonly.' [aiida-sshonly]
WARNING! No bdist_wheel available for PyPI release [aiida-statefile-schedulers]
WARNING! AiiDA version not found [aiida-statefile-schedulers]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-statefile-schedulers]
WARNING! No bdist_wheel available for PyPI release [aiida-strain]
WARNING! AiiDA version not found [aiida-strain]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-supercell]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-supercell]
WARNING! No bdist_wheel available for PyPI release [aiida-symmetry-representation]
WARNING! AiiDA version not found [aiida-symmetry-representation]
WARNING! No bdist_wheel available for PyPI release [aiida-tbextraction]
WARNING! AiiDA version not found [aiida-tbextraction]
WARNING! No bdist_wheel available for PyPI release [aiida-tbmodels]
WARNING! AiiDA version not found [aiida-tbmodels]
WARNING! Missing classifier 'Framework :: AiiDA' [aiida-tcod]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-tcod]
WARNING! Entry point 'UppASD_core_calculations' does not start with prefix 'uppasd.' [aiida-uppasd]
WARNING! Entry point 'UppASD_core_parsers' does not start with prefix 'uppasd.' [aiida-uppasd]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-wannier90-workflows]
WARNING! Cannot fetch all data from PyPI and missing plugin_info key! [aiida-wien2k]
WARNING! AiiDA version not found [aiida-wien2k]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-yambo]
WARNING! AiiDA version not found [aiida-yascheduler]
WARNING! > WARNING! Unable to retrieve plugin info from: https://raw.githubusercontent.com/antimomarrazzo/aiida-z2pack/master/setup.json [aiida-z2pack]
WARNING! AiiDA version not found [aiida-z2pack]
WARNING! No bdist_wheel available for PyPI release [aiida-zeopp]
WARNING! AiiDA version not found [aiida-zeopp]
WARNING! development_status key is deprecated. Use PyPI Trove classifiers in the plugin repository instead. [aiida-zeopp]

Please sign in to comment.