mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Make OrgNode tags stable sorted to find new entries for incremental updates
- Having Tags as sets was returning them in a different order everytime - This resulted in spuriously identifying existing entries as new because their tags ordering changed - Converting tags to list fixes the issue and identifies updated new entries for incremental update correctly
This commit is contained in:
parent
2f7a6af56a
commit
b9a6e80629
2 changed files with 10 additions and 10 deletions
|
@ -64,7 +64,7 @@ def makelist(filename):
|
||||||
level = 0
|
level = 0
|
||||||
heading = ""
|
heading = ""
|
||||||
bodytext = ""
|
bodytext = ""
|
||||||
tags = set() # set of all tags in headline
|
tags = list() # set of all tags in headline
|
||||||
closed_date = ''
|
closed_date = ''
|
||||||
sched_date = ''
|
sched_date = ''
|
||||||
deadline_date = ''
|
deadline_date = ''
|
||||||
|
@ -98,14 +98,14 @@ def makelist(filename):
|
||||||
level = hdng.group(1)
|
level = hdng.group(1)
|
||||||
heading = hdng.group(2)
|
heading = hdng.group(2)
|
||||||
bodytext = ""
|
bodytext = ""
|
||||||
tags = set() # set of all tags in headline
|
tags = list() # set of all tags in headline
|
||||||
tagsrch = re.search(r'(.*?)\s*:([a-zA-Z0-9].*?):$',heading)
|
tagsrch = re.search(r'(.*?)\s*:([a-zA-Z0-9].*?):$',heading)
|
||||||
if tagsrch:
|
if tagsrch:
|
||||||
heading = tagsrch.group(1)
|
heading = tagsrch.group(1)
|
||||||
parsedtags = tagsrch.group(2)
|
parsedtags = tagsrch.group(2)
|
||||||
if parsedtags:
|
if parsedtags:
|
||||||
for parsedtag in parsedtags.split(':'):
|
for parsedtag in parsedtags.split(':'):
|
||||||
if parsedtag != '': tags.add(parsedtag)
|
if parsedtag != '': tags.append(parsedtag)
|
||||||
else: # we are processing a non-heading line
|
else: # we are processing a non-heading line
|
||||||
if line[:10] == '#+SEQ_TODO':
|
if line[:10] == '#+SEQ_TODO':
|
||||||
kwlist = re.findall(r'([A-Z]+)\(', line)
|
kwlist = re.findall(r'([A-Z]+)\(', line)
|
||||||
|
@ -217,7 +217,7 @@ class Orgnode(object):
|
||||||
self.level = len(level)
|
self.level = len(level)
|
||||||
self.headline = headline
|
self.headline = headline
|
||||||
self.body = body
|
self.body = body
|
||||||
self.tags = set(tags) # All tags in the headline
|
self.tags = tags # All tags in the headline
|
||||||
self.todo = ""
|
self.todo = ""
|
||||||
self.prty = "" # empty of A, B or C
|
self.prty = "" # empty of A, B or C
|
||||||
self.scheduled = "" # Scheduled date
|
self.scheduled = "" # Scheduled date
|
||||||
|
@ -270,8 +270,8 @@ class Orgnode(object):
|
||||||
|
|
||||||
def Tags(self):
|
def Tags(self):
|
||||||
"""
|
"""
|
||||||
Returns the set of all tags
|
Returns the list of all tags
|
||||||
For example, :HOME:COMPUTER: would return {'HOME', 'COMPUTER'}
|
For example, :HOME:COMPUTER: would return ['HOME', 'COMPUTER']
|
||||||
"""
|
"""
|
||||||
return self.tags
|
return self.tags
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ class Orgnode(object):
|
||||||
"""
|
"""
|
||||||
Store all the tags found in the headline.
|
Store all the tags found in the headline.
|
||||||
"""
|
"""
|
||||||
self.tags = set(newtags)
|
self.tags = newtags
|
||||||
|
|
||||||
def Todo(self):
|
def Todo(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -23,7 +23,7 @@ Body Line 1'''
|
||||||
# Assert
|
# Assert
|
||||||
assert len(entries) == 1
|
assert len(entries) == 1
|
||||||
assert entries[0].Heading() == "Heading"
|
assert entries[0].Heading() == "Heading"
|
||||||
assert entries[0].Tags() == set()
|
assert entries[0].Tags() == list()
|
||||||
assert entries[0].Body() == "Body Line 1"
|
assert entries[0].Body() == "Body Line 1"
|
||||||
assert entries[0].Priority() == ""
|
assert entries[0].Priority() == ""
|
||||||
assert entries[0].Property("ID") == ""
|
assert entries[0].Property("ID") == ""
|
||||||
|
@ -57,7 +57,7 @@ Body Line 2'''
|
||||||
assert len(entries) == 1
|
assert len(entries) == 1
|
||||||
assert entries[0].Heading() == "Heading"
|
assert entries[0].Heading() == "Heading"
|
||||||
assert entries[0].Todo() == "DONE"
|
assert entries[0].Todo() == "DONE"
|
||||||
assert entries[0].Tags() == {"Tag1", "TAG2", "tag3"}
|
assert entries[0].Tags() == ["Tag1", "TAG2", "tag3"]
|
||||||
assert entries[0].Body() == "- Clocked Log 1\nBody Line 1\nBody Line 2"
|
assert entries[0].Body() == "- Clocked Log 1\nBody Line 1\nBody Line 2"
|
||||||
assert entries[0].Priority() == "A"
|
assert entries[0].Priority() == "A"
|
||||||
assert entries[0].Property("ID") == "id:123-456-789-4234-1231"
|
assert entries[0].Property("ID") == "id:123-456-789-4234-1231"
|
||||||
|
@ -158,7 +158,7 @@ Body 2
|
||||||
for index, entry in enumerate(entries):
|
for index, entry in enumerate(entries):
|
||||||
assert entry.Heading() == f"Heading{index+1}"
|
assert entry.Heading() == f"Heading{index+1}"
|
||||||
assert entry.Todo() == "FAILED" if index == 0 else "CANCELLED"
|
assert entry.Todo() == "FAILED" if index == 0 else "CANCELLED"
|
||||||
assert entry.Tags() == {f"tag{index+1}"}
|
assert entry.Tags() == [f"tag{index+1}"]
|
||||||
assert entry.Body() == f"- Clocked Log {index+1}\nBody {index+1}\n\n"
|
assert entry.Body() == f"- Clocked Log {index+1}\nBody {index+1}\n\n"
|
||||||
assert entry.Priority() == "A"
|
assert entry.Priority() == "A"
|
||||||
assert entry.Property("ID") == f"id:123-456-789-4234-000{index+1}"
|
assert entry.Property("ID") == f"id:123-456-789-4234-000{index+1}"
|
||||||
|
|
Loading…
Reference in a new issue