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: Add the name of the image contributor #953

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/src/model/product_image.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'off_tagged.dart';
import '../utils/language_helper.dart';
import '../utils/open_food_api_configuration.dart';
import '../utils/uri_helper.dart';
import 'off_tagged.dart';

enum ImageField implements OffTagged {
FRONT(offTag: 'front'),
Expand Down Expand Up @@ -122,6 +122,7 @@ class ProductImage {
this.y2,
this.width,
this.height,
this.contributor,
});

ProductImage.raw({
Expand All @@ -131,6 +132,7 @@ class ProductImage {
this.width,
this.height,
this.uploaded,
this.contributor,
}) : language = null,
field = null;

Expand All @@ -142,6 +144,9 @@ class ProductImage {
/// Upload timestamp, for uploaded images only, in seconds since Unix Epoch.
DateTime? uploaded;

/// Contributor of this image
String? contributor;

/// Revision number
int? rev;

Expand Down
2 changes: 2 additions & 0 deletions lib/src/utils/json_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class JsonHelper {

// only for raw images
static const String _ALL_IMAGES_TAG_UPLOADED = 'uploaded_t';
static const String _ALL_IMAGES_TAG_UPLOADER = 'uploader';

// common to main and raw images
static const String _ALL_IMAGES_TAG_IMAGE_ID = 'imgid';
Expand Down Expand Up @@ -169,6 +170,7 @@ class JsonHelper {
height: JsonObject.parseInt(numberObject[_ALL_IMAGES_TAG_HEIGHT]),
url: numberObject[_ALL_IMAGES_TAG_URL],
uploaded: uploaded,
contributor: fieldObject[_ALL_IMAGES_TAG_UPLOADER],
Copy link
Contributor

Choose a reason for hiding this comment

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

_ALL_IMAGES_TAG_UPLOADED appears in both allImagesToJson and allImagesFromJson.
In your code _ALL_IMAGES_TAG_UPLOADER appears only once. Probably something needs to be fixed.
Additional unit tests would help, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't include the 'to' method on purpose, because today, images are well assigned to the contributor.
But I can add do, no pb.

In terms of tests, despite checking the result of the server, I don't really see any benefits here.

),
);
}
Expand Down