-
Notifications
You must be signed in to change notification settings - Fork 40
Use case: CIEL Markdown changelog using OCL engine #859
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
base: master
Are you sure you want to change the base?
Changes from all commits
3e8e6e6
02a22cc
4f9cc41
124bdca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -880,20 +880,30 @@ def generate_key(*args, **kwargs): | |
| return "|".join(key_parts) | ||
|
|
||
| @app.task(base=QueueOnceCustomTask) | ||
| def source_version_compare(version1_uri, version2_uri, is_changelog, verbosity, ignore_cache=False): | ||
| def source_version_compare(version1_uri, version2_uri, is_changelog, verbosity, ignore_cache=False, format_type='json'): | ||
| ignore_cache = ignore_cache or get(settings, 'TEST_MODE', False) | ||
| # Include format_type in the cache key only when it differs from the default | ||
| # to avoid invalidating existing cached JSON results. | ||
| cache_key_suffix = f'|format={format_type}' if format_type != 'json' else '' | ||
| if not ignore_cache: | ||
| cache_key = generate_key( | ||
| 'source_version_compare', version1_uri, version2_uri, is_changelog, verbosity) | ||
| 'source_version_compare', version1_uri, version2_uri, is_changelog, verbosity) + cache_key_suffix | ||
| result = cache.get(cache_key) | ||
| if result: | ||
| return result | ||
|
|
||
| from core.sources.models import Source | ||
| version1 = Source.objects.get(uri=version1_uri) | ||
| version2 = Source.objects.get(uri=version2_uri) | ||
| fn = Source.changelog if is_changelog else Source.compare | ||
| result = fn(version1, version2, verbosity) | ||
|
|
||
| if is_changelog: | ||
| result = Source.changelog(version1, version2, verbosity) | ||
| if format_type == 'markdown': | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for markdown should I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The format is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. following the Ideally the API should be Following RFC convention |
||
| from core.sources.changelog_markdown import ChangelogMarkdownGenerator | ||
| result['markdown'] = ChangelogMarkdownGenerator(result).generate() | ||
| else: | ||
| result = Source.compare(version1, version2, verbosity) | ||
|
|
||
| if not ignore_cache: | ||
| cache.set(cache_key, result, timeout=60*60*24*4) | ||
| return result | ||
Uh oh!
There was an error while loading. Please reload this page.