|
6 | 6 | from dotenv import load_dotenv
|
7 | 7 | from github import Github
|
8 | 8 |
|
9 |
| -from supported import get_unimplemented_and_implemented_commands, download_redis_commands |
| 9 | +from supported import download_redis_commands, implemented_commands |
10 | 10 |
|
11 | 11 | load_dotenv() # take environment variables from .env.
|
12 | 12 |
|
13 | 13 | IGNORE_GROUPS = {
|
14 | 14 | 'server', 'cf', 'cms', 'topk', 'tdigest', 'bf', 'search', 'suggestion', 'timeseries',
|
15 | 15 | 'graph', 'server', 'cluster', 'connection',
|
16 |
| - 'server', 'cluster', 'list', 'connection', 'bitmap', 'sorted-set', 'generic', 'scripting', 'geo', 'hash', |
17 |
| - 'hyperloglog', 'pubsub', 'stream', 'graph', 'timeseries', 'search', 'suggestion', 'bf', 'cf', 'cms', 'topk', |
18 |
| - 'tdigest', 'json', |
| 16 | + 'server', 'cluster', 'list', 'connection', 'bitmap', 'sorted-set', 'generic', 'scripting', |
| 17 | + 'hyperloglog', 'pubsub', 'graph', 'timeseries', 'search', 'suggestion', 'bf', 'cf', 'cms', 'topk', |
| 18 | + 'tdigest', |
| 19 | + 'stream', |
19 | 20 | }
|
20 | 21 | IGNORE_COMMANDS = {
|
21 | 22 | 'PUBSUB HELP',
|
|
28 | 29 | 'JSON.DEBUG MEMORY',
|
29 | 30 | 'JSON.DEBUG',
|
30 | 31 | 'JSON.TYPE',
|
31 |
| - 'JSON.OBJKEYS', |
32 |
| - 'JSON.OBJLEN', |
33 |
| - 'JSON.ARRTRIM', |
34 |
| - 'JSON.ARRAPPEND', |
35 |
| - 'JSON.ARRINDEX', |
36 |
| - 'JSON.ARRINSERT', |
37 |
| - 'JSON.ARRLEN', |
38 |
| - 'JSON.ARRPOP', |
39 |
| - 'JSON.NUMINCRBY', |
40 |
| - 'JSON.NUMMULTBY', |
41 | 32 | 'JSON.RESP',
|
42 | 33 | }
|
43 | 34 |
|
44 | 35 |
|
| 36 | +def commands_groups( |
| 37 | + all_commands: dict, implemented_set: set |
| 38 | +) -> tuple[dict[str, list[str]], dict[str, list[str]]]: |
| 39 | + implemented, unimplemented = dict(), dict() |
| 40 | + for cmd in all_commands: |
| 41 | + if cmd.upper() in IGNORE_COMMANDS: |
| 42 | + continue |
| 43 | + group = all_commands[cmd]['group'] |
| 44 | + unimplemented.setdefault(group, []) |
| 45 | + implemented.setdefault(group, []) |
| 46 | + if cmd in implemented_set: |
| 47 | + implemented[group].append(cmd) |
| 48 | + else: |
| 49 | + unimplemented[group].append(cmd) |
| 50 | + return implemented, unimplemented |
| 51 | + |
| 52 | + |
| 53 | +def get_unimplemented_and_implemented_commands() -> tuple[dict[str, list[str]], dict[str, list[str]]]: |
| 54 | + """Returns 2 dictionaries, one of unimplemented commands and another of implemented commands |
| 55 | +
|
| 56 | + """ |
| 57 | + commands = download_redis_commands() |
| 58 | + implemented_commands_set = implemented_commands() |
| 59 | + implemented_dict, unimplemented_dict = commands_groups(commands, implemented_commands_set) |
| 60 | + groups = sorted(implemented_dict.keys(), key=lambda x: len(unimplemented_dict[x])) |
| 61 | + for group in groups: |
| 62 | + unimplemented_count = len(unimplemented_dict[group]) |
| 63 | + total_count = len(implemented_dict.get(group)) + unimplemented_count |
| 64 | + print(f'{group} has {unimplemented_count}/{total_count} unimplemented commands') |
| 65 | + return unimplemented_dict, implemented_dict |
| 66 | + |
| 67 | + |
45 | 68 | class GithubData:
|
46 |
| - def __init__(self, dry=False): |
| 69 | + def __init__(self, dry=True): |
47 | 70 | token = os.getenv('GITHUB_TOKEN', None)
|
48 | 71 | g = Github(token)
|
49 | 72 | self.dry = dry or (token is None)
|
|
0 commit comments