mirror of
https://github.com/PretendoNetwork/juxtaposition-ui.git
synced 2026-09-11 10:55:32 -05:00
Added database support for sub-communities and post replies
This commit is contained in:
committed by
Jay Poffinbarger
parent
9a7ccd2d3c
commit
e51c82ce5a
@@ -49,19 +49,26 @@ async function getTopicByCommunityID(communityID) {
|
||||
async function getCommunities(numberOfCommunities) {
|
||||
verifyConnected();
|
||||
if(numberOfCommunities === -1)
|
||||
return COMMUNITY.find({});
|
||||
return COMMUNITY.find({ parent: null });
|
||||
else
|
||||
return COMMUNITY.find({}).limit(numberOfCommunities);
|
||||
return COMMUNITY.find({ parent: null }).limit(numberOfCommunities);
|
||||
}
|
||||
|
||||
async function getMostPopularCommunities(numberOfCommunities) {
|
||||
verifyConnected();
|
||||
return COMMUNITY.find({}).sort({followers: -1}).limit(numberOfCommunities);
|
||||
return COMMUNITY.find({ parent: null }).sort({followers: -1}).limit(numberOfCommunities);
|
||||
}
|
||||
|
||||
async function getNewCommunities(numberOfCommunities) {
|
||||
verifyConnected();
|
||||
return COMMUNITY.find({}).sort([['created_at', -1]]).limit(numberOfCommunities);
|
||||
return COMMUNITY.find({ parent: null }).sort([['created_at', -1]]).limit(numberOfCommunities);
|
||||
}
|
||||
|
||||
async function getSubCommunities(communityID) {
|
||||
verifyConnected();
|
||||
return COMMUNITY.find({
|
||||
parent: communityID
|
||||
});
|
||||
}
|
||||
|
||||
async function getCommunityByTitleID(title_id) {
|
||||
@@ -100,6 +107,21 @@ async function getPostsByUserID(userID) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getPostReplies(postID, number) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
parent: postID
|
||||
}).limit(number);
|
||||
}
|
||||
|
||||
async function getUserPostRepliesAfterTimestamp(post, numberOfPosts) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
parent: post.pid,
|
||||
created_at: { $lt: post.created_at }
|
||||
}).limit(numberOfPosts);
|
||||
}
|
||||
|
||||
async function getNumberUserPostsByID(userID, number) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
@@ -165,8 +187,6 @@ async function getNewPostsByCommunity(community, numberOfPosts) {
|
||||
}).sort({ created_at: -1 }).limit(numberOfPosts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function getUserPostsAfterTimestamp(post, numberOfPosts) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
@@ -224,6 +244,7 @@ module.exports = {
|
||||
getCommunities,
|
||||
getMostPopularCommunities,
|
||||
getNewCommunities,
|
||||
getSubCommunities,
|
||||
getCommunityByTitleID,
|
||||
getCommunityByID,
|
||||
getTotalPostsByCommunity,
|
||||
@@ -236,6 +257,8 @@ module.exports = {
|
||||
getNewPostsByCommunity,
|
||||
getPostsByCommunityKey,
|
||||
getPostsByUserID,
|
||||
getPostReplies,
|
||||
getUserPostRepliesAfterTimestamp,
|
||||
getNumberUserPostsByID,
|
||||
getTotalPostsByUserID,
|
||||
getPostByID,
|
||||
|
||||
@@ -41,6 +41,10 @@ const CommunitySchema = new Schema({
|
||||
CTR_browser_header: String,
|
||||
WiiU_browser_header: String,
|
||||
description: String,
|
||||
parent: {
|
||||
type: Number,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
CommunitySchema.methods.upEmpathy = async function() {
|
||||
|
||||
@@ -63,6 +63,10 @@ const PostSchema = new Schema({
|
||||
verified: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
parent: {
|
||||
type: Number,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const juxt_web = require('./services/juxt-web');
|
||||
app.set('etag', false);
|
||||
app.disable('x-powered-by');
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', __dirname + '\\webfiles');
|
||||
app.set('views', __dirname + '/webfiles');
|
||||
|
||||
// Create router
|
||||
logger.info('Setting up Middleware');
|
||||
|
||||
Reference in New Issue
Block a user