Skip to content

Commit

Permalink
Merge pull request #102 from CMU-17313Q/prettier
Browse files Browse the repository at this point in the history
Added developer tool called Prettier
  • Loading branch information
khiyami authored Oct 27, 2024
2 parents b369da1 + 22d26ef commit b860689
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi":"true",
"singleQuote":"true",
"trailingComa":"es5",
"useTabs":"true",
"arrowParens":"avoid",
"printWidth":80,
"tabWidth":2,
"bracketSpacing": true
}
1 change: 1 addition & 0 deletions install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"zxcvbn": "4.4.2"
},
"devDependencies": {
"prettier": "3.3.3",
"jshint": "^2.13.6",
"flow-bin":"^0.250.0",
"@stryker-mutator/core": "^8.6.0",
Expand Down
35 changes: 26 additions & 9 deletions src/categories/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,40 @@ const cache = require('../cache');

module.exports = function (Categories) {
Categories.purge = async function (cid, uid) {
await batch.processSortedSet(`cid:${cid}:tids`, async (tids) => {
await async.eachLimit(tids, 10, async (tid) => {
await topics.purgePostsAndTopic(tid, uid);
});
}, { alwaysStartAt: 0 });
await batch.processSortedSet(
`cid:${cid}:tids`,
async (tids) => {
await async.eachLimit(tids, 10, async (tid) => {
await topics.purgePostsAndTopic(tid, uid);
});
},
{ alwaysStartAt: 0 },
);

const pinnedTids = await db.getSortedSetRevRange(`cid:${cid}:tids:pinned`, 0, -1);
const pinnedTids = await db.getSortedSetRevRange(
`cid:${cid}:tids:pinned`,
0,
-1,
);
await async.eachLimit(pinnedTids, 10, async (tid) => {
await topics.purgePostsAndTopic(tid, uid);
});
const categoryData = await Categories.getCategoryData(cid);
await purgeCategory(cid, categoryData);
plugins.hooks.fire('action:category.delete', { cid: cid, uid: uid, category: categoryData });
plugins.hooks.fire('action:category.delete', {
cid: cid,
uid: uid,
category: categoryData,
});
};

async function purgeCategory(cid, categoryData) {
const bulkRemove = [['categories:cid', cid]];
if (categoryData && categoryData.name) {
bulkRemove.push(['categories:name', `${categoryData.name.slice(0, 200).toLowerCase()}:${cid}`]);
bulkRemove.push([
'categories:name',
`${categoryData.name.slice(0, 200).toLowerCase()}:${cid}`,
]);
}
await db.sortedSetRemoveBulk(bulkRemove);

Expand All @@ -51,7 +66,9 @@ module.exports = function (Categories) {
`category:${cid}`,
]);
const privilegeList = await privileges.categories.getPrivilegeList();
await groups.destroy(privilegeList.map(privilege => `cid:${cid}:privileges:${privilege}`));
await groups.destroy(
privilegeList.map(privilege => `cid:${cid}:privileges:${privilege}`),
);
}

async function removeFromParent(cid) {
Expand Down

0 comments on commit b860689

Please sign in to comment.