Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project names as uniq identifiers #5

Open
yolk opened this issue Jan 26, 2022 · 15 comments
Open

Project names as uniq identifiers #5

yolk opened this issue Jan 26, 2022 · 15 comments

Comments

@yolk
Copy link
Contributor

yolk commented Jan 26, 2022

miteclock expects project names to be uniq in mite. But this isn't the case. A lot of mite.users use the same project name for different projects per customer.

For example:

» m start a p 'This and that'
'Alltag' matched the following multiple projects:
Alltag
Alltag

Please provide an unambiguous pattern.

It would be very helpful to have a simple way to specify the customer name in a project shortcut.
Alternatively, why not ask on first usage (instead of the error message shown above) which project from which customer to use and store it in the config file?

Also m status only shows the project name. It would be helpful to also show the customer. The name of the customer is included in the project.json as customer_name.

@iliakur
Copy link
Owner

iliakur commented Jan 26, 2022

Oh, I was totally unaware of the customer name scope, interesting!

I don't have a feeling about the ergonomics of the workflow here, do you mind answering some questions about it?

  1. Do users who have the same project for different customers expect to compose those, i.e. m start a a... for ACME Alltag and m start b a for BBC Alltag?
  2. How common is it to search by both project name and customer id? i.e. something like this in the config file: a = {name='Alltag', customer='ACME'}

@yolk
Copy link
Contributor Author

yolk commented Jan 26, 2022

  1. I would not go this route, because it somewhat contradicts the whole idea behind shortcuts. Would be better to allow them to add shortcuts like m start aa ... for ACME Alltag and m start ba for BBC Alltag.
  2. Something like this would be perfect to specify the exact projects in the shortcuts.

@iliakur
Copy link
Owner

iliakur commented Feb 24, 2022

Hey! Sorry, I've been a bit unresponsive, a lot happening at work. I'll have time now, however, to chip away at this consistently!

@iliakur
Copy link
Owner

iliakur commented May 5, 2022

@yolk I've pushed a new release where this and #4 have been implemented. Let me know what you think!

Especially welcome are ideas for how to document this behavior :)

@yolk
Copy link
Contributor Author

yolk commented May 9, 2022

Thanks for the update! Tried to play around with it, but I can't figure out how to specify the client in the TOML-file. Could you give me a quick example?

@iliakur
Copy link
Owner

iliakur commented May 9, 2022

aha, the missing docs strike again!

Here's an example:

x = {project = 'test', client = 'ACME'}

@yolk
Copy link
Contributor Author

yolk commented May 9, 2022

Thx for the example!

But when I put this in my config:

[shortcuts] # Add your shortcuts inside this section.
a = {project = 'Alltag', client = 'mite'}
z = "Zukunft"
p = "Programmierung"

miteclock throws an error:

$: m start a p                                                                                                            ruby31-puma
Traceback (most recent call last):
  File "/usr/local/bin/m", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/miteclock/cli.py", line 169, in start
    spec = to_time_entry_spec(activity, settings.shortcuts, projects, services)
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 151, in to_time_entry_spec
    else find_unique(projects, "projects", proj_pattern)["id"]
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 118, in find_unique
    matched = [e for e in entries if pattern.matches(e)]
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 118, in <listcomp>
    matched = [e for e in entries if pattern.matches(e)]
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 109, in __call__
    return all(pred(entry) for pred in self.predicates)
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 109, in <genexpr>
    return all(pred(entry) for pred in self.predicates)
  File "/usr/local/lib/python3.9/site-packages/miteclock/activities.py", line 101, in __call__
    return self.pattern in entry[self.fieldname]
KeyError: 'client_name'

Any idea?

@yolk
Copy link
Contributor Author

yolk commented May 9, 2022

"If" I understand your code correctly, you are using the filedname "client_name" in your test data. But the mite.api returns the field as "customer_name". Maybe this is the problem?

@iliakur
Copy link
Owner

iliakur commented May 9, 2022

Yes, you're right, I've pushed a fix!

@iliakur
Copy link
Owner

iliakur commented May 10, 2022

Do you think the fieldname "customer" would be better than "client"? I was, as usual, trying to save keystrokes, but maybe it's better to stay consistent with mite terminology :)

@yolk
Copy link
Contributor Author

yolk commented May 11, 2022

Thanks for the fix. It is working now!

And yes, I would stay more consistent with the mite terminology.

For the documentational aspect: it would be pretty useful (and I guess quiet easy) to change the error from

'Alltag' matched the following multiple projects:
Alltag
Alltag

Please provide an unambiguous pattern.

to something like this:

'Alltag' matched the following projects:
    Alltag (Customer: X)
    Alltag (Customer: Y)

Please provide an unambiguous pattern
in your config file, like:
    {project = 'Alltag', customer = 'X'}

@iliakur
Copy link
Owner

iliakur commented May 13, 2022

Oki-doki, I'll release those changes next week when I'm back at the computer. Thanks for all the feedback!

@yolk
Copy link
Contributor Author

yolk commented May 13, 2022

Thanks! Another idea, regarding customers:

~ » m status
The clock is running!

Below is the entry being tracked.
Project: Open-Source
Service: QA
Note:
Time spent: 0h0m

Total time clocked in today: 0h0m

It would be good to add another line ala Customer: XYZ or append a suffix to the project line (Project: Open-Source (XYZ)). I guess the extra line would be better, because some of the mite clients use rather long names for projects and/or customers.

@iliakur
Copy link
Owner

iliakur commented May 23, 2022

Hi @yolk!

Thanks very much for all the feedback. I've implemented most of it:

  • client -> customer
  • Client information (if present) is now displayed for projects in error messages and also in m show projects.
  • A new section in the README describes more "advanced" shortcut definitions, which includes the feature in this ticket.

It turned out that suggesting a pattern is not that trivial, so I've left that for a future date.

Give release 22.3 a spin and let me know what you think!

@iliakur
Copy link
Owner

iliakur commented Jul 5, 2022

Hmm, the way I'm displaying projects right now confuses a colleague of mine who doesn't know about the whole "customer" angle.

He thought that "Project name (Customer name)" are all part of the project name. I think we can solve this with some documentation as well as better markup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants