Skip to content

Commit

Permalink
dailycalls grouped into a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Jul 19, 2022
1 parent 8e8bb61 commit 8b22f3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
- Fix: Using native date picker in modern browsers
- Most UI components turned into modules, using emotion to avoid css conflicts
- Removed load generator menu entry since it won't be used anymore
- Fix: dailycalls were not limited to 20 per user
- Now dailycalls are split by user, to speed up api calls

- Update notes:
- npm install required (emotion and babel dependencies)
- config.yaml `callinfoPath` should point to the parent of current `my_calls_log`.
If not specified it will be `callinfo` by default (relative to the working path).
- config.yaml: `my_calls_log` should be removed
- day
- `callinfo/dailycalls.yaml` not used anymore,
now `callinfo/dailycalls/calls-[user].yaml is used

## 4.6.0 2022-07-12

Expand Down
6 changes: 3 additions & 3 deletions tomatic/callregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ class CallRegistry(object):
def __init__(self, path=None, size=20):
self.path = Path(path or CONFIG.callinfoPath)
self.path.mkdir(parents=True, exist_ok=True)
self.callregistry_path = self.path / 'dailycalls.yaml'
self.size = size

def _calls(self, user):
callregistry = self.path / f'dailycalls-{user}.yaml'
callregistry = self.path / f'dailycalls/calls-{user}.yaml'
if not callregistry.exists():
return ns(calls=[])
return ns.load(callregistry)
Expand All @@ -30,7 +29,7 @@ def callsByUser(self, user):

def updateCall(self, user, fields):
calls = self.callsByUser(user)
callregistry = self.path / f'dailycalls-{user}.yaml'
callregistry = self.path / f'dailycalls/calls-{user}.yaml'

for call in calls:
if call.date == fields.date:
Expand All @@ -42,6 +41,7 @@ def updateCall(self, user, fields):
if self.size:
del calls[:-self.size]

callregistry.parent.mkdir(parents=True, exist_ok=True)
ns(calls=calls).dump(callregistry)

def annotateCall(self, fields):
Expand Down
3 changes: 2 additions & 1 deletion tomatic/callregistry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setUp(self):
self.dir.mkdir()

def dailycalls(self, user):
return self.dir / f'dailycalls-{user}.yaml'
return self.dir / f'dailycalls/calls-{user}.yaml'

def tearDown(self):
removeTree(self.dir)
Expand Down Expand Up @@ -283,6 +283,7 @@ def test_annotateCall_writesFiles(self):
'test_callregistry/cases',
'test_callregistry/cases/{:%Y%m%d}.yaml'.format(
date.today()),
'test_callregistry/dailycalls',
str(self.dailycalls('alice')),
])

Expand Down

0 comments on commit 8b22f3f

Please sign in to comment.