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

Changes to encode differently no-recommendations signal; and also avo… #2075

Merged
merged 1 commit into from
Oct 19, 2020
Merged
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
60 changes: 31 additions & 29 deletions src/js/react/Recommender/components/RecommendedList.jsx.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
define([
'react',
'react-prop-types',
'react-redux',
'react-bootstrap',
'../actions',
], function(
define(['react', 'react-prop-types', 'react-redux', '../actions'], function(
React,
PropTypes,
{ useSelector, useDispatch },
{ Button },
{ getRecommendations, getFullList, emitAnalytics }
{ getRecommendations, emitAnalytics }
) {
const Paper = ({ title, bibcode, author, totalAuthors, onClick }) => {
const el = React.useRef(null);
Expand Down Expand Up @@ -71,61 +64,65 @@ define([

var executed = 0;
var userName = null;
var reported = false;
const selector = (state) => {
// reset if it is a different user
if (state.userName !== userName) {
executed = 0;
userName = state.userName;
reported = false;
}

return {
getRecommendationsRequest: state.requests.GET_RECOMMENDATIONS,
getDocsRequest: state.requests.GET_DOCS,
docs: state.docs,
queryParams: state.queryParams,
executed: executed
executed: executed,
reported: reported,
};
};

const RecommendedList = () => {
const dispatch = useDispatch();
/*
const onGetMore = () => {
dispatch(getFullList());
};
*/

const {
getRecommendationsRequest,
getDocsRequest,
docs,
queryParams,
userName
userName // eslint-disable-line
} = useSelector(selector);

React.useEffect(() => {
if ((executed + 12*60*60*1000) < Date.now()) {
if (executed + 12 * 60 * 60 * 1000 < Date.now()) {
// the hook gets called too many times even with [docs] in the args to useEffect
// (and oracle returns 404 when nothing is found; which is IMHO wrong) but we can't
// rely on status.failure for that reason
executed = Date.now();
dispatch(getRecommendations());
}
else {
if (executed && getDocsRequest && getDocsRequest.status && docs.length === 0) {
// we are rendered (send the signal everytime -- even if it was sent already)
dispatch(
emitAnalytics([
'send',
'event',
'interaction.recommendation', // category
'no-useful-recommendations', // action
'', // label,
0, // value
])
);
}
reported = false;
} else if (executed && docs.length === 0 && !reported) {
// we are rendered (send the signal everytime -- even if it was sent already)
dispatch(
emitAnalytics([
'send',
'event',
'interaction.no-recommendation', // category
'no-useful-recommendations', // action
'', // label,
0, // value
])
);
reported = true;
}
});


const onPaperSelect = ({ bibcode }, index) => {
dispatch(
emitAnalytics([
Expand Down Expand Up @@ -173,7 +170,12 @@ define([
if (docs.length === 0) {
return (
<Message>
Sorry, we don't have any recommendations for you just yet! ADS provides users recommendations based on their reading history, and we suggest that you create an ADS account to take advantage of this feature. If you already have an account, then be sure you are logged in while searching and reading papers. In due time we will be able to provide you with suggestions based on your inferred interests.
Sorry, we do not have any recommendations for you just yet! ADS
provides users recommendations based on their reading history, and we
suggest that you create an ADS account to take advantage of this
feature. If you already have an account, then be sure you are logged
in while searching and reading papers. In due time we will be able to
provide you with suggestions based on your inferred interests.
</Message>
);
}
Expand Down