Skip to content

Commit

Permalink
- Added alphabetical sorting to of handlers.
Browse files Browse the repository at this point in the history
- Fixed scaling of handlers yet again, related SplitScreen-Me#18.
- Made hover animation less prevalent, related SplitScreen-Me#31.
- Changed api endpoint `api/v1/totalDownloadCountEver` to `api/v1/hubstats`, and added som more stuff to it, related SplitScreen-Me#45.
  • Loading branch information
Snailedlt committed Sep 20, 2021
1 parent c130576 commit 86d7ab6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 22 deletions.
2 changes: 1 addition & 1 deletion client/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
}

.ant-card:hover {
transform: scale(1.1);
transform: scale(1.05);
}
58 changes: 46 additions & 12 deletions imports/api/Handlers/server/publications.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Handlers from '../Handlers';
import escapeRegExp from "../../../modules/regexescaper";
import Packages from "../../Packages/server/ServerPackages";
import Comments from '../../Comments/Comments';
import escapeRegExp from '../../../modules/regexescaper';
import Packages from '../../Packages/server/ServerPackages';

Meteor.publish(
'handlers',
function handlers(handlerTitleSearch = '', handlerOptionSearch = 'hot', handlerSortOrder = 'down', limit = 18) {
let sortObject = { stars: handlerSortOrder === "up" ? 1 : -1 };
function handlers(
handlerTitleSearch = '',
handlerOptionSearch = 'hot',
handlerSortOrder = 'down',
limit = 18,
) {
let sortObject = { stars: handlerSortOrder === 'up' ? 1 : -1 };
if (handlerOptionSearch === 'download') {
sortObject = { downloadCount: handlerSortOrder === "up" ? 1 : -1 };
sortObject = { downloadCount: handlerSortOrder === 'up' ? 1 : -1 };
}
if (handlerOptionSearch === 'latest') {
sortObject = { createdAt: handlerSortOrder === "up" ? 1 : -1 };
sortObject = { createdAt: handlerSortOrder === 'up' ? 1 : -1 };
}
if (handlerOptionSearch === 'report') {
sortObject = { reports: handlerSortOrder === "up" ? 1 : -1 };
sortObject = { reports: handlerSortOrder === 'up' ? 1 : -1 };
}
if (handlerOptionSearch === 'alphabetical') {
sortObject = { gameName: handlerSortOrder === 'up' ? -1 : 1 };
}
return Handlers.find(
{
Expand Down Expand Up @@ -64,14 +73,39 @@ Meteor.publish(
},
);

WebApp.connectHandlers.use('/api/v1/totalDownloadCountEver', async (req, res, next) => {
WebApp.connectHandlers.use('/api/v1/hubstats', async (req, res, next) => {
res.writeHead(200);
let sum = 0;
let downloadsSum = 0;
let hotnessSum = 0;
let handlerCount = 0;
let usersCount = 0;
const allPackages = Packages.collection.find({}).fetch();
allPackages.forEach(pkg => {
if (pkg.meta.downloads > 0) sum = sum + pkg.meta.downloads;
if (pkg.meta.downloads > 0) {
downloadsSum = downloadsSum + pkg.meta.downloads;
}
});
const allHandlers = Handlers.find({ private: false }).fetch();
allHandlers.forEach(hndl => {
if (hndl.stars > 0) {
hotnessSum = hotnessSum + hndl.stars;
}
});
res.end(`Total downloads: ${sum}`);
handlerCount = allHandlers.length;

const allUsers = Meteor.users.find({}).fetch();
usersCount = allUsers.length;

const allComments = Comments.find({}).fetch();
const commentsCount = allComments.length;

res.end(
`Total downloads: ${downloadsSum}` +
`\nTotal hotness: ${hotnessSum}` +
`\nTotal handlers: ${handlerCount}` +
`\nTotal users: ${usersCount}` +
`\nTotal comments ${commentsCount}`
);
});

Meteor.publish('handlers.edit', function handlersEdit(documentId) {
Expand Down Expand Up @@ -104,7 +138,7 @@ Meteor.publish(
private: false,
},
{
sort: {stars: -1},
sort: { stars: -1 },
limit: 500,
},
);
Expand Down
2 changes: 1 addition & 1 deletion imports/ui/layouts/App/AppMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function AppMenu(props) {
<a href="https://www.splitscreen.me">
<Icon
component={() => (
<img src="splitscreen-me-logo.png" height="35px" alt="SplitScreen Me logo" />
<img src="../splitscreen-me-logo.png" height="35px" alt="SplitScreen Me logo" />
)}
/>
SplitScreen Me
Expand Down
22 changes: 14 additions & 8 deletions imports/ui/pages/Handlers/Handlers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ function Handlers(props) {
{props.currentSearchOption === 'latest' && <Icon type={props.currentOrder} />} Release
date
</Radio.Button>
<Radio.Button onClick={onSortOrderChange} value="alphabetical">
{props.currentSearchOption === 'alphabetical' && <Icon type={props.currentOrder} />} Alphabetical
</Radio.Button>
{isAdmin && (
<Radio.Button onClick={onSortOrderChange} value="report">
{props.currentSearchOption === 'report' && <Icon type={props.currentOrder} />} Reports
Expand All @@ -137,13 +140,13 @@ function Handlers(props) {
<List
size="large"
grid={{
gutter: 10,
gutter: 60,
xs: 1,
sm: 2,
md: 3,
lg: 4,
xl: 4,
xxl: 5,
sm: 1,
md: 2,
lg: 3,
xl: 3,
xxl: 4,
}}
dataSource={props.handlers}
footer={
Expand All @@ -152,7 +155,7 @@ function Handlers(props) {
</div>
}
renderItem={item => (
<List.Item key={item._id}>
<List.Item key={item._id} style={{ paddingBottom: '30px' }}>
<Card
cover={
<Link
Expand All @@ -163,7 +166,7 @@ function Handlers(props) {
<div
style={{
width: 'auto',
height: '360px',
height: '550px',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center center',
Expand Down Expand Up @@ -335,6 +338,9 @@ export default withTracker(() => {
if (currentSearchOption.get() === 'report') {
sortObject = { reports: reactiveCurrentOrder === 'up' ? 1 : -1 };
}
if (currentSearchOption.get() === 'alphabetical') {
sortObject = { gameName: reactiveCurrentOrder === 'up' ? -1 : 1 };
}

return {
loading: !subscription.ready(),
Expand Down

0 comments on commit 86d7ab6

Please sign in to comment.