filters:
  and:
    - file.ext == "md"
formulas:
  createdDate: created_at
  modifiedDate: modified_at
  finishedDate: done_date
  testFormula: if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
  Name: if(title, link(file, title), file)
  Type: |-
    if(
    date(if(formula.createdDate, formula.createdDate, file.ctime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), "🌱 NEW", 

    if(
    date(if(formula.modifiedDate, formula.modifiedDate, file.mtime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), "📝 MODIFIED", "OTHERS"

    )
    )

    + if(file.inFolder("WebClip"), " 🗃️ ", "")

    + if(formula.finishedDate, 
    if (
    date(formula.finishedDate).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), " ✅ DONE", ""
    ), ""
    )
  statusGroup: |+
    if(
    date(if(formula.createdDate, formula.createdDate, file.ctime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), "Today Created", 

    if (
    date(formula.finishedDate).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), "Today Finished",

    if(
    date(if(formula.modifiedDate, formula.modifiedDate, file.mtime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD"), "Today Modified", "OTHERS"

    )
    )
    )

views:
  - type: table
    name: All of Today
    filters:
      and:
        - and:
            - '!file.inFolder("PeriodicNote")'
            - '!file.inFolder("_global")'
        - or:
            - date(if(formula.modifiedDate, formula.modifiedDate, file.mtime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
            - date(if(formula.createdDate, formula.createdDate, file.ctime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
            - formula.finishedDate && date(formula.finishedDate).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
    groupBy: formula.statusGroup
    order:
      - formula.Name
      - formula.Type
    sort:
      - property: formula.Type
        direction: ASC
    columnSize:
      formula.Name: 361
  - type: table
    name: Recently Finished
    filters:
      and:
        - formula.finishedDate >= today() - "7 day"
    order:
      - file.name
      - formula.finishedDate
    sort:
      - property: formula.finishedDate
        direction: DESC
    columnSize:
      file.name: 663
  - type: table
    name: Recently Modified
    filters:
      and:
        - formula.createdDate >= today() - "7 day" || formula.modifiedDate >= today() - "3 day"
    sort:
      - property: file.name
        direction: ASC
  - type: table
    name: Modified Today
    filters:
      and:
        - date(if(formula.modifiedDate, formula.modifiedDate, file.mtime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
        - '!file.inFolder("PeriodicNote")'
        - date(if(formula.createdDate, formula.createdDate, file.ctime)).format("YYYYMMDD") != if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
    order:
      - formula.Name
    columnSize:
      file.name: 438
  - type: table
    name: Created Today
    filters:
      and:
        - date(if(formula.createdDate, formula.createdDate, file.ctime)).format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
        - '!file.inFolder("PeriodicNote")'
    order:
      - formula.Name
      - formula.createdDate
      - formula.modifiedDate
    columnSize:
      formula.Name: 575
      formula.createdDate: 134
  - type: table
    name: Finished Today
    filters:
      and:
        - formula.finishedDate && formula.finishedDate.format("YYYYMMDD") == if(/^\d{4}-\d{2}-\d{2}/.matches(this.file.name), date(this.file.name), today()).format("YYYYMMDD")
        - '!file.inFolder("PeriodicNote")'
    order:
      - formula.Name
    columnSize:
      formula.Name: 701
