Skip to content

Commit

Permalink
Merge branch 'main' into RemoveColumnsFromEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro authored Nov 14, 2023
2 parents 6f466eb + f920230 commit 7ffba8b
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 128 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v2.44.8 - 2023-11-14

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.44.7...v2.44.8)

- [#6929](https://github.com/ORCID/ORCID-Source/pull/6929): Changed the code to use triples

## v2.44.7 - 2023-11-09

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.44.6...v2.44.7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public interface ProfileDao extends GenericDao<ProfileEntity, String> {
void updateLastModifiedDateAndIndexingStatusWithoutResult(String orcid, Date lastModified, IndexingStatus indexingStatus);

public List<Triple<String, Boolean, Date>> findEmailsUnverfiedDays(int daysUnverified, int maxResults);


public List<Triple<String, Boolean, String>> findEmailsUnverifiedDaysByEventType(int daysUnverified, int tooOldNumberOfDays);

String retrieveOrcidType(String orcid);

List<Object[]> findInfoForDecryptionAnalysis();
Expand Down Expand Up @@ -156,10 +158,10 @@ public interface ProfileDao extends GenericDao<ProfileEntity, String> {
public List<Object[]> getSigninLock(String orcid);

public void startSigninLock(String orcid);

public void resetSigninLock(String orcid);

public void updateSigninLock(String orcid, Integer count);

boolean haveMemberPushedWorksOrAffiliationsToRecord(String orcid, String clientId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProfileDaoImpl extends GenericDaoImpl<ProfileEntity, String> implements ProfileDao {

private static final String PRIVATE_VISIBILITY = "PRIVATE";

private static final Logger LOGGER = LoggerFactory.getLogger(ProfileDaoImpl.class);

@Value("${org.orcid.postgres.query.timeout:30000}")
private Integer queryTimeout;

Expand Down Expand Up @@ -150,7 +155,31 @@ public List<Triple<String, Boolean, Date>> findEmailsUnverfiedDays(int daysUnver
results.add(pair);
});
return results;
}
}

@SuppressWarnings("unchecked")
@Override
public List<Triple<String, Boolean, String>> findEmailsUnverifiedDaysByEventType(int daysUnverified, int tooOldNumberOfDays) {
StringBuilder queryString = new StringBuilder("SELECT e.email, e.is_primary, ev.email_event_type FROM email e ");
queryString.append("LEFT JOIN email_event ev ON e.email = ev.email ");
queryString.append("JOIN profile p on p.orcid = e.orcid and p.claimed = true ");
queryString.append("AND p.deprecated_date is null AND p.profile_deactivation_date is null AND p.account_expiry is null ");
queryString.append("where e.is_verified = false ");
queryString.append("and e.date_created between (now() - CAST('").append(tooOldNumberOfDays).append("' AS INTERVAL DAY)) and (now() - CAST('")
.append(daysUnverified).append("' AS INTERVAL DAY)) ");
queryString.append("and e.date_created < (now() - CAST('").append(daysUnverified).append("' AS INTERVAL DAY)) ");
queryString.append("and (e.source_id = e.orcid OR e.source_id is null)");
queryString.append(" ORDER BY e.last_modified");

Query query = entityManager.createNativeQuery(queryString.toString());
List<Object[]> dbInfo = query.getResultList();
List<Triple<String, Boolean, String>> results = new ArrayList<Triple<String, Boolean, String>>();
dbInfo.stream().forEach(element -> {
Triple<String, Boolean, String> pair = Triple.of((String) element[0], (Boolean) element[1], (String) element[2]);
results.add(pair);
});
return results;
}

@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -785,7 +814,7 @@ public void startSigninLock(String orcid) {
query.executeUpdate();
return;
}

@Override
@Transactional
public void resetSigninLock(String orcid) {
Expand All @@ -809,18 +838,18 @@ public void updateSigninLock(String orcid, Integer count) {
query.executeUpdate();
return;
}

public boolean haveMemberPushedWorksOrAffiliationsToRecord(String orcid, String clientId) {
try {
String queryString = "select p.orcid from profile p where p.orcid = :orcid and ( exists (select 1 from work w where w.orcid = p.orcid and w.client_source_id = :clientId) or exists (select 1 from org_affiliation_relation o where o.orcid = p.orcid and o.client_source_id = :clientId));";
Query query = entityManager.createNativeQuery(queryString);
query.setParameter("orcid", orcid);
query.setParameter("clientId", clientId);
String result = (String) query.getSingleResult();
if(orcid.equals(result)) {
if (orcid.equals(result)) {
return true;
}
} catch(NoResultException nre) {
}
} catch (NoResultException nre) {
return false;
}
return false;
Expand Down
Loading

0 comments on commit 7ffba8b

Please sign in to comment.