on master help sign in
correct grants count
commit79c2711d8a1f1b7bc73dbe8a596942439f76025c authorGavin Atkinson <gvnatknsn@protonmail.com> dateTue 6 Jul 2021, 14:57 (5 years ago) parentd2deb9a
1 file changed+7−6
lib/lib.js+7−6
lib/lib.js+7−6
@@ -160,7 +160,6 @@ export function formatDate(d) {
160160// }
161161
162162export function buildPageTree(path, ordering = "", content = false) {
163− // get metadata from _index.md file in each folder. This is where page ordering (weight) is stored.
164163 const metadata = matter(fs.readFileSync(join(path, "_index.md")), options);
165164 // get a list of contents at the path, with file types so that the item at the path can be identified as file or folder
166165 const children = fs.readdirSync(path, { withFileTypes: true });
@@ -189,7 +188,6 @@ export function buildPageTree(path, ordering = "", content = false) {
189188 }),
190189 };
191190 })
192− // Sort files according to weight. Weight can be a date or number. The choice between the two is set by the 'ordering' param.
193191 .sort((a, b) => a.weight - b.weight),
194192 children: Object.fromEntries(
195193 subdirs.map((subdir) => [
@@ -278,12 +276,15 @@ export function getOpenGrantsCount() {
278276 .map((path) =>
279277 matter(fs.readFileSync(join(directories.grants, path)), options)
280278 )
281− // Count non-completed grants
279+ // Count grants which are both uncompleted and not assigned
282280 .reduce((acc, metadata) => {
283− if (metadata.data.extra.completed) {
284− return acc;
281+ if (
282+ !metadata.data.extra.completed &&
283+ metadata.data.extra.assignee === ""
284+ ) {
285+ return acc + 1;
285286 }
286− return acc + 1;
287+ return acc;
287288 }, 0);
288289 return count;
289290}