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

feat(obligation_import): Add functionality to import obligations via … #47

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

deo002
Copy link
Collaborator

@deo002 deo002 commented Feb 29, 2024

Add functionality to import obligations via a json file
JSON file format example:

[
    {
        "topic": "Provide Copyright Notices",
        "type": "obligation",
        "text": "Text 2",
        "classification": "green",
        "modifications": true,
        "comment": "",
        "shortnames": ["LGPL-3.0-or-later","QPL-1.0","GPL-1.0-only","GPL-1.0-or-later"],
        "active": true,
        "text_updatable": true
    },
    {
        "topic": "provide license upstream",
        "type": "obligation",
        "text": "Text",
        "modifications": false,
        "comment": "",
        "shortnames": ["LGPL-2.1-only"],
        "active": true,
        "text_updatable": true
    }
]

@deo002 deo002 requested a review from GMishx February 29, 2024 11:37
pkg/api/obligations.go Outdated Show resolved Hide resolved
pkg/api/obligations.go Outdated Show resolved Hide resolved
pkg/api/obligations.go Outdated Show resolved Hide resolved
pkg/api/obligations.go Outdated Show resolved Hide resolved
pkg/models/types.go Outdated Show resolved Hide resolved
@deo002 deo002 force-pushed the obligation_import branch 2 times, most recently from de097ee to bd53fc6 Compare April 2, 2024 06:08
@deo002 deo002 requested a review from GMishx April 2, 2024 06:11
@GMishx
Copy link
Member

GMishx commented Apr 4, 2024

The import works partially. I tried to import 3 obligations.

  1. Changed the obligation comment -> worked
  2. Changed the obligation topic but not text -> failed as expected
  3. New obligation with new text -> Obligation is created with the correct topic but rest fields contains default values.

I guess, the FirstOrCreate() only created the obligation with given condition in Where(). Since the Updates() was not called afterwards, the values were not updated (other than topic).

@deo002 deo002 force-pushed the obligation_import branch from 6003b9d to 9db5946 Compare April 4, 2024 08:31
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good.
Tested, working as expected.

@GMishx GMishx merged commit c5a1a8c into fossology:main Apr 4, 2024
5 checks passed
@GMishx GMishx deleted the obligation_import branch April 4, 2024 10:24
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

Successfully merging this pull request may close these issues.

2 participants