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

IQSS/9506 thumbnail failure tracking and other performance improvements #9669

Merged
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
502e660
suppress thumb generation after a failure
qqmyers May 12, 2023
0fea5cc
refactor error
qqmyers May 12, 2023
8f5350a
cache isThumb available
qqmyers May 15, 2023
8604eef
set thumb fail column
qqmyers May 15, 2023
aeae8f4
use thumb wrapper in edit and view files
qqmyers May 15, 2023
c4ad20b
add api
qqmyers May 17, 2023
63e98b3
make clearer
qqmyers May 17, 2023
2671cb7
update comment
qqmyers May 17, 2023
19db99b
remove setting flag where datafile is not clearly being saved to db
qqmyers May 17, 2023
156d025
fix non-merge-able error when recording thumb fail
qqmyers Jun 1, 2023
97aa46c
rename script
qqmyers Jun 13, 2023
dbc36c9
refactor - remove duplicate code
qqmyers Jun 13, 2023
0c89723
try ds logos as url requests
qqmyers Jun 14, 2023
dc4b6ae
set the datasetid for search cards
qqmyers Jun 14, 2023
546cfdf
fix non-merge-able error when recording thumb fail
qqmyers Jun 1, 2023
d3a48df
typo
qqmyers Jun 14, 2023
f505428
only send url if thumb should exist
qqmyers Jun 19, 2023
2d177a6
use inputStream.transferTo
qqmyers Jun 19, 2023
6540b5d
add debug
qqmyers Jun 19, 2023
e202d0a
more debug
qqmyers Jun 19, 2023
b9cd2bb
include failed preview flag in queries
qqmyers Jun 20, 2023
ac5a956
use getThumbnailByVersionId
qqmyers Jun 20, 2023
98acd6b
cleanup
qqmyers Jun 20, 2023
faaa33d
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Jun 20, 2023
610c65d
rename and cleanup
qqmyers Jun 21, 2023
391504d
api docs
qqmyers Jun 21, 2023
de7963a
refactor typo
qqmyers Jun 21, 2023
cd0502d
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Jul 5, 2023
f17a97b
Merge branch 'IQSS/9555-update_listCurationStates_api_call' of
qqmyers Jul 12, 2023
a580d00
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Jul 12, 2023
f421a44
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Aug 4, 2023
9847bb9
Merge remote-tracking branch 'IQSS/develop' into
qqmyers Sep 12, 2023
cf9ca5a
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Oct 10, 2023
35eac7e
Merge remote-tracking branch 'IQSS/develop' into IQSS/9506-thumbnail-…
qqmyers Nov 28, 2023
aa75382
address review comments - unused imports/method
qqmyers Nov 28, 2023
b90a1d7
update flyway number
qqmyers Nov 28, 2023
e088d11
Merge branch 'develop' into IQSS/9506-thumbnail-tracking #9506
pdurbin Nov 30, 2023
d647f81
tweak docs, add new APIs to API changelog #9506
pdurbin Nov 30, 2023
4ad06ba
rename previewshavefailed to previewimagefail #9506
pdurbin Nov 30, 2023
7148158
add tests #9506
pdurbin Nov 30, 2023
67502ca
fix typos #9506
pdurbin Nov 30, 2023
82f0bc0
one more rename to previewimagefail #9506
pdurbin Nov 30, 2023
0c02b15
try QDR /logo endpoint
qqmyers Dec 5, 2023
7349ed9
get logo, picking 48px size for datafile thumbs
qqmyers Dec 5, 2023
c3b4412
Merge remote-tracking branch 'IQSS/develop' into
qqmyers Dec 5, 2023
dfa49c3
rename flyway script
qqmyers Dec 5, 2023
5149941
Merge branch 'develop' into IQSS/9506-thumbnail-tracking #9506
pdurbin Dec 5, 2023
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
22 changes: 21 additions & 1 deletion doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5334,7 +5334,6 @@ A curl example using allowing access to a dataset's metadata
Please see :ref:`dataverse.api.signature-secret` for the configuration option to add a shared secret, enabling extra
security.


.. _send-feedback:

Send Feedback To Contact(s)
Expand Down Expand Up @@ -5362,6 +5361,7 @@ A curl example using an ``ID``
Note that this call could be useful in coordinating with dataset authors (assuming they are also contacts) as an alternative/addition to the functionality provided by :ref:`return-a-dataset`.



MyData
------

Expand Down Expand Up @@ -5399,3 +5399,23 @@ Parameters:

``per_page`` Number of results returned per page.


.. _thumbnail_reset:

Reset Thumbnail Failure Flags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If Dataverse attempts to create a thumbnail image for an image or pdf file and the attempt fails, Dataverse will set a flag for the file to avoid repeated attempts to generate the thumbnail.
For cases where the problem may have been temporary (or fixed in a later Dataverse release), two API calls exist to reset this flag for all files or for a given file.

Curl examples

.. code-block:: bash

export SERVER_URL=http://localhost
export fileID=1234

curl -X DELETE $SERVER_URL/api/admin/clearThumbnailFailureFlag

curl -X DELETE $SERVER_URL/api/admin/clearThumbnailFailureFlag/$fileID

20 changes: 10 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/DataFileServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ public boolean isThumbnailAvailable (DataFile file) {
}

// If thumbnails are not even supported for this class of files,
// there's notthing to talk about:
// there's nothing to talk about:
if (!FileUtil.isThumbnailSupported(file)) {
return false;
}
Expand All @@ -980,16 +980,16 @@ public boolean isThumbnailAvailable (DataFile file) {
is more important...

*/


if (ImageThumbConverter.isThumbnailAvailable(file)) {
file = this.find(file.getId());
file.setPreviewImageAvailable(true);
this.save(file);
return true;
}

return false;
file = this.find(file.getId());
if (ImageThumbConverter.isThumbnailAvailable(file)) {
file.setPreviewImageAvailable(true);
this.save(file);
return true;
}
file.setPreviewsHaveFailed(true);
this.save(file);
return false;
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public String getThumbnailString() {

thumbnailString = datasetThumbnail.getBase64image();
} else {
thumbnailString = thumbnailServiceWrapper.getDatasetCardImageAsBase64Url(dataset,
thumbnailString = thumbnailServiceWrapper.getDatasetCardImageAsUrl(dataset,
workingVersion.getId(),
!workingVersion.isDraft(),
ImageThumbConverter.DEFAULT_DATASETLOGO_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ public Long getThumbnailByVersionId(Long versionId) {
+ "AND df.id = o.id "
+ "AND fm.datasetversion_id = dv.id "
+ "AND fm.datafile_id = df.id "
// + "AND o.previewImageAvailable = false "
+ "AND o.previewshavefailed = false "
+ "AND df.restricted = false "
+ "AND df.embargo_id is null "
+ "AND df.contenttype LIKE 'image/%' "
Expand Down Expand Up @@ -859,7 +859,7 @@ public Long getThumbnailByVersionId(Long versionId) {
+ "AND df.id = o.id "
+ "AND fm.datasetversion_id = dv.id "
+ "AND fm.datafile_id = df.id "
// + "AND o.previewImageAvailable = false "
+ "AND o.previewshavefailed = false "
+ "AND df.restricted = false "
+ "AND df.embargo_id is null "
+ "AND df.contenttype = 'application/pdf' "
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/edu/harvard/iq/dataverse/DataverseServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,51 +346,6 @@ public String getDataverseLogoThumbnailAsBase64ById(Long dvId) {
}
return null;
}

/*
public boolean isDataverseLogoThumbnailAvailable(Dataverse dataverse, User user) {
if (dataverse == null) {
return false;
}

// First, check if the dataverse has a defined logo:

//if (dataverse.getDataverseTheme() != null && dataverse.getDataverseTheme().getLogo() != null && !dataverse.getDataverseTheme().getLogo().equals("")) {
File dataverseLogoFile = getLogo(dataverse);
if (dataverseLogoFile != null) {
String logoThumbNailPath = null;

if (dataverseLogoFile.exists()) {
logoThumbNailPath = ImageThumbConverter.generateImageThumbnailFromFile(dataverseLogoFile.getAbsolutePath(), 48);
if (logoThumbNailPath != null) {
return true;
}
}
}
//}
*/
// If there's no uploaded logo for this dataverse, go through its
// [released] datasets and see if any of them have card images:
//
// TODO:
// Discuss/Decide if we really want to do this - i.e., go through every
// file in every dataset below...
// -- L.A. 4.0 beta14
/*
for (Dataset dataset : datasetService.findPublishedByOwnerId(dataverse.getId())) {
if (dataset != null) {
DatasetVersion releasedVersion = dataset.getReleasedVersion();

if (releasedVersion != null) {
if (datasetService.isDatasetCardImageAvailable(releasedVersion, user)) {
return true;
}
}
}
} */
/*
return false;
} */

private File getLogo(Dataverse dataverse) {
if (dataverse.getId() == null) {
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DvObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,23 @@ public boolean isPreviewImageAvailable() {
public void setPreviewImageAvailable(boolean status) {
this.previewImageAvailable = status;
}

/**
* Indicates whether a previous attempt to generate a preview image has failed,
* regardless of size. This could be due to the file not being accessible, or a
* real failure in generating the thumbnail. In both cases, we won't want to try
* again every time the preview/thumbnail is requested for a view.
*/
private boolean previewsHaveFailed;

public boolean isPreviewsHaveFailed() {
return previewsHaveFailed;
}

public void setPreviewsHaveFailed(boolean previewsHaveFailed) {
this.previewsHaveFailed = previewsHaveFailed;
}

public Timestamp getModificationTime() {
return modificationTime;
}
Expand Down Expand Up @@ -465,6 +481,7 @@ public void setStorageIdentifier(String storageIdentifier) {
*/
public abstract boolean isAncestorOf( DvObject other );


@OneToMany(mappedBy = "definitionPoint",cascade={ CascadeType.REMOVE, CascadeType.MERGE,CascadeType.PERSIST}, orphanRemoval=true)
List<RoleAssignment> roleAssignments;
}
Loading
Loading