Simplified queries
This commit is contained in:
@@ -204,35 +204,23 @@ class Obsidian():
|
|||||||
|
|
||||||
return self._safe_call(call_fn)
|
return self._safe_call(call_fn)
|
||||||
|
|
||||||
def get_recent_changes(self, limit: int = 10, days: int = 90, extensions: list = None) -> Any:
|
def get_recent_changes(self, limit: int = 10, days: int = 90) -> Any:
|
||||||
"""Get recently modified files in the vault.
|
"""Get recently modified files in the vault.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
limit: Maximum number of files to return (default: 10)
|
limit: Maximum number of files to return (default: 10)
|
||||||
days: Only include files modified within this many days (default: 90)
|
days: Only include files modified within this many days (default: 90)
|
||||||
extensions: Only include files with these extensions (optional)
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of recently modified files with metadata
|
List of recently modified files with metadata
|
||||||
"""
|
"""
|
||||||
# Build the DQL query based on parameters
|
# Build the DQL query
|
||||||
query_lines = ["TABLE file.mtime"]
|
query_lines = [
|
||||||
|
"TABLE file.mtime",
|
||||||
# Add WHERE clauses
|
f"WHERE file.mtime >= date(today) - dur({days} days)",
|
||||||
where_clauses = []
|
"SORT file.mtime DESC",
|
||||||
if days is not None:
|
f"LIMIT {limit}"
|
||||||
where_clauses.append(f"file.mtime >= date(today) - dur({days} days)")
|
]
|
||||||
|
|
||||||
if extensions:
|
|
||||||
ext_list = ", ".join(f'"{ext}"' for ext in extensions)
|
|
||||||
where_clauses.append(f"file.ext IN ({ext_list})")
|
|
||||||
|
|
||||||
if where_clauses:
|
|
||||||
query_lines.append(f"WHERE {' AND '.join(where_clauses)}")
|
|
||||||
|
|
||||||
# Add sorting and limit
|
|
||||||
query_lines.append("SORT file.mtime DESC")
|
|
||||||
query_lines.append(f"LIMIT {limit}")
|
|
||||||
|
|
||||||
# Join with proper DQL line breaks
|
# Join with proper DQL line breaks
|
||||||
dql_query = "\n".join(query_lines)
|
dql_query = "\n".join(query_lines)
|
||||||
|
Reference in New Issue
Block a user