Skip to content

Commit

Permalink
code cleaning + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Exr0n committed Aug 16, 2021
1 parent f46ecbe commit 6db68d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Objects/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,10 @@ async function BootstrapCondution(context:Context, username:string, payload:stri
async function ParseABTIBIntention(context:Context, intention:string) {
const ABTIB_PROJECT_PATTERN = /for (.+)$/;

console.log(intention)
let dateInfo = chrono.parse(intention, undefined, { forwardDate: true }); // some issues here: https://github.com/wanasit/chrono/issues/402
let due = undefined;
let defer = undefined;
intention = intention.trim();
if (dateInfo.length > 0) {
// we got a date!
if (dateInfo[0].end) {
Expand All @@ -846,14 +846,14 @@ async function ParseABTIBIntention(context:Context, intention:string) {
// see if the intention has a project specifier
const project = await (async () => {
const proj_matches = intention.trim().match(ABTIB_PROJECT_PATTERN);
if (proj_matches === null) return undefined;
const name = proj_matches[1];
const projs = await (new Query(context)).execute(
if (proj_matches === null) return undefined; // do nothing if theres no intention to add to project
const name = proj_matches[1]; // the first capture group
const projs = await (new Query(context)).execute( // all non-completed projects
Project,
(proj: Project) => !proj.isComplete,
) as Project[];
const matches = projs.filter(p => p.name === name);
if (matches.length === 1) {
const matches = projs.filter(p => p.name === name); // get all projects that they could be thinking of
if (matches.length === 1) { // only add it if theres exactly one
intention = intention.replace(ABTIB_PROJECT_PATTERN, '').trim();
return matches[0];
}
Expand Down

0 comments on commit 6db68d4

Please sign in to comment.