From 107b2e6d7fffa720df123568c6eb0a553cc00b0e Mon Sep 17 00:00:00 2001 From: Roman Chyla Date: Thu, 2 Apr 2020 02:23:54 -0400 Subject: [PATCH 01/24] AB testing made easy --- src/config/common.config.js | 6 ++++ src/config/discovery.config.js | 1 + src/config/discovery.vars.js.default | 2 ++ src/js/components/experiments.js | 52 ++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 src/js/components/experiments.js diff --git a/src/config/common.config.js b/src/config/common.config.js index 6d532f5fe..4687b1d23 100644 --- a/src/config/common.config.js +++ b/src/config/common.config.js @@ -55,6 +55,12 @@ define([], function() { config.googleTrackingCode || '', config.googleTrackingOptions ); + + if (config.googleOptimizeCode) { + qa('require', config.googleOptimizeCode); + if (!config.debugExportBBB) + console.warn('AB testing will be loaded, but bbb object is not exposed. Change debugExportBBB if needed.'); + } }); }, 0); }); diff --git a/src/config/discovery.config.js b/src/config/discovery.config.js index 159ca5752..6d592fc7d 100644 --- a/src/config/discovery.config.js +++ b/src/config/discovery.config.js @@ -37,6 +37,7 @@ require.config({ Orcid: 'js/modules/orcid/module', SecondOrderController: 'js/components/second_order_controller', HotkeysController: 'js/components/hotkeys_controller', + Experiments: 'js/components/experiments', }, services: { Api: 'js/services/api', diff --git a/src/config/discovery.vars.js.default b/src/config/discovery.vars.js.default index a90eca9b6..a1eb1b763 100644 --- a/src/config/discovery.vars.js.default +++ b/src/config/discovery.vars.js.default @@ -80,6 +80,8 @@ define([], function() { */ googleTrackingCode: 'UA-XXXXXXXX-X', googleTrackingOptions: 'auto', + googleOptimizeCode: null, + googleOptimizeOptions: null, /** diff --git a/src/js/components/experiments.js b/src/js/components/experiments.js new file mode 100644 index 000000000..6dba444df --- /dev/null +++ b/src/js/components/experiments.js @@ -0,0 +1,52 @@ +define(['underscore', + 'jquery', + 'js/components/generic_module', + 'js/mixins/dependon'], + function(_, + $, + GenericModule, + Dependon + ) { + + var Experiments = GenericModule.extend({ + initialize: function() { + // store all metadata entries here + this.isRunning = false; + }, + + activate: function(beehive, app) { + this.setApp(app); + this.setBeeHive(beehive); + var pubsub = this.getPubSub(); + pubsub.subscribe( + pubsub.ARIA_ANNOUNCEMENT, + _.bind(this.onAppStarted, this) + ); + }, + + onAppStarted: function() { + this.toggleOptimize(); + //var self = this; + //setTimeout(function() {self.toggleOptimize(), 1000}); // won't be necessary if I knew what event to listen to... + + }, + + toggleOptimize: function() { + if (dataLayer === null) { + console.warn('Optimize is not available'); + return; + } + + if (this.isRunning) { + dataLayer.push({'event': 'optimize.deactivate'}); + } + else { + dataLayer.push({'event': 'optimize.activate'}); + } + this.isRunning = !this.isRunning; + } + }); + _.extend(Experiments.prototype, Dependon.BeeHive, Dependon.App); + + return Experiments; +}); \ No newline at end of file From 2415f1a2f8d75de1e3eb31d8462834995908b219 Mon Sep 17 00:00:00 2001 From: Roman Chyla Date: Wed, 8 Apr 2020 21:09:38 -0400 Subject: [PATCH 02/24] Updated config to use analytics loaded from proxy --- src/config/discovery.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/discovery.config.js b/src/config/discovery.config.js index 6d592fc7d..e4144417d 100644 --- a/src/config/discovery.config.js +++ b/src/config/discovery.config.js @@ -222,7 +222,7 @@ require.config({ '//cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min', 'libs/file-saver/index', ], - 'google-analytics': ['libs/g', 'data:application/javascript,'], + 'google-analytics': ['/analytics/analytics', 'libs/g', 'data:application/javascript,'], hbs: 'libs/require-handlebars-plugin/hbs', hotkeys: 'libs/hotkeys/index', jquery: 'libs/jquery/jquery', From 91f9aeeb565c0d36b98e4f945393903f7e3d192e Mon Sep 17 00:00:00 2001 From: Tim Hostetler <6970899+thostetler@users.noreply.github.com> Date: Mon, 13 Apr 2020 16:02:45 -0400 Subject: [PATCH 03/24] initial stuff --- src/js/react/Recommender/actions.js | 25 + .../react/Recommender/components/App.jsx.js | 38 ++ .../components/RecommendedList.jsx.js | 571 ++++++++++++++++++ .../components/SearchExamples.jsx.js | 86 +++ src/js/react/Recommender/containers/main.js | 3 + src/js/react/Recommender/index.js | 23 + src/js/react/Recommender/middleware.js | 25 + src/js/react/Recommender/models/index.js | 5 + .../Recommender/models/searchExamples.js | 68 +++ src/js/react/Recommender/reducer.js | 32 + .../templates/search_bar_template.html | 73 --- .../landing-page-layout.html | 11 +- .../landing_page_manager.js | 12 + 13 files changed, 890 insertions(+), 82 deletions(-) create mode 100644 src/js/react/Recommender/actions.js create mode 100644 src/js/react/Recommender/components/App.jsx.js create mode 100644 src/js/react/Recommender/components/RecommendedList.jsx.js create mode 100644 src/js/react/Recommender/components/SearchExamples.jsx.js create mode 100644 src/js/react/Recommender/containers/main.js create mode 100644 src/js/react/Recommender/index.js create mode 100644 src/js/react/Recommender/middleware.js create mode 100644 src/js/react/Recommender/models/index.js create mode 100644 src/js/react/Recommender/models/searchExamples.js create mode 100644 src/js/react/Recommender/reducer.js diff --git a/src/js/react/Recommender/actions.js b/src/js/react/Recommender/actions.js new file mode 100644 index 000000000..2c685f060 --- /dev/null +++ b/src/js/react/Recommender/actions.js @@ -0,0 +1,25 @@ +define([], function() { + const actions = { + GET_RECOMMENDATIONS: 'GET_RECOMMENDATIONS', + }; + + const actionCreators = { + getRecommendations: ({ func, sort, numDocs, cutOffDays, topNReads }) => ({ + type: 'API_REQUEST', + scope: actions.GET_RECOMMENDATIONS, + options: { + type: 'POST', + target: `_oracle/readhist`, + body: { + function: func, + sort, + num_docs: numDocs, + cutoff_days: cutOffDays, + top_n_reads: topNReads, + }, + }, + }), + }; + + return { ...actions, ...actionCreators }; +}); diff --git a/src/js/react/Recommender/components/App.jsx.js b/src/js/react/Recommender/components/App.jsx.js new file mode 100644 index 000000000..2c6cad621 --- /dev/null +++ b/src/js/react/Recommender/components/App.jsx.js @@ -0,0 +1,38 @@ +define([ + 'react', + 'react-bootstrap', + 'react-prop-types', + 'es6!./RecommendedList.jsx', + 'es6!./SearchExamples.jsx', +], function( + React, + { Nav, NavItem }, + PropTypes, + RecommendedList, + SearchExamples +) { + const App = () => { + const [selected, onSelected] = React.useState(1); + + return ( +
+ + {selected === 1 ? : } +
+ ); + }; + + return App; +}); diff --git a/src/js/react/Recommender/components/RecommendedList.jsx.js b/src/js/react/Recommender/components/RecommendedList.jsx.js new file mode 100644 index 000000000..a3a13d4d7 --- /dev/null +++ b/src/js/react/Recommender/components/RecommendedList.jsx.js @@ -0,0 +1,571 @@ +define(['react', 'react-prop-types', 'react-redux', '../actions'], function( + React, + PropTypes, + { useSelector, useDispatch }, + { getRecommendations } +) { + const papers = [ + { + title: + 'New BVR photometry and first light curve analysis of the W UMa type eclipsing binary V2240 Cyg', + bibcode: '2020NewA...7901391O', + author: ['Ostadnezhad, S.', 'Forozani, Gh.', 'Ghanaatian, M.'], + }, + { + title: + 'Multi-wavelength study in the region of IRAS 16571-4029 and 16575-4023 sources', + bibcode: '2020NewA...7901384B', + author: [ + 'Baume, G.', + 'Corti, M. A.', + 'Borissova, J.', + 'Ramirez Alegria, S.', + 'Corvera, A. V.', + ], + }, + { + title: + 'Miscellaneous photometric variations in cataclysmic variables: V455 And, SS Cyg, AQ Men, LQ Peg, RW Tri and UX UMa', + bibcode: '2020NewA...7801369B', + author: ['Bruch, Albert'], + }, + { + title: + 'Study of open cluster King 13 using CCD VI, 2MASS and Gaia DR2 Astrometry.', + bibcode: '2020NewA...7801364D', + author: [ + 'Durgapal, Alok', + 'Bisht, D.', + 'Rangwal, Geeta', + 'Kaur, Harmeen', + 'Yadav, R. K. S.', + ], + }, + { + title: + 'Photometric study and kinematics of the EL CVn type eclipsing binary: WASP 1628+10', + bibcode: '2020NewA...7801363L', + author: ['Luo, Yangping'], + }, + { + title: + 'Photometric and periodic investigations of W-type W UMa eclipsing binary BB Peg', + bibcode: '2020NewA...7801354K', + author: ['Kamalifar, Z.', 'Abedi, A.', 'Roobiat, K. Y.'], + }, + { + title: + 'End-of-mission calibration of the Cassini Imaging Science Subsystem', + bibcode: '2020P&SS..18504898K', + author: [ + 'Knowles, Benjamin', + 'West, Robert', + 'Helfenstein, Paul', + 'Verbiscer, Anne', + 'Wilson, Daren', + 'Porco, Carolyn', + ], + }, + { + title: + 'Dark matter stars from beyond General Relativity models: Magnetosphere dynamics and torsion fields', + bibcode: '2020JHEAp..26...21C', + author: ['Cirilo-Lombardo, D. J.'], + }, + { + title: + 'NIKA2 observations around LBV stars Emission from stars and circumstellar material', + bibcode: '2020EPJWC.22800023R', + author: ['Ricardo Rizzo, J.', 'Ritacco, Alessia', 'Bordiu, Cristobal'], + }, + { + title: + 'Observing with NIKA2Pol from the IRAM 30m telescope : Early results on the commissioning phase', + bibcode: '2020EPJWC.22800022R', + author: [ + 'Ritacco, A.', + 'Adam, R.', + 'Ade, P.', + 'Ajeddig, H.', + 'André, P.', + 'Andrianasolo, A.', + 'Aussel, H.', + 'Beelen, A.', + 'Benoît, A.', + 'Bideaud, A.', + 'Bourrion, O.', + 'Calvo, M.', + 'Catalano, A.', + 'Comis, B.', + 'De Petris, M.', + 'Désert, F. -X.', + 'Doyle, S.', + 'Driessen, E. F. C.', + 'Gomez, A.', + 'Goupy, J.', + 'Kéruzoré, F.', + 'Kramer, C.', + 'Ladjelate, B.', + 'Lagache, G.', + 'Leclercq, S.', + 'Lestrade, J. -F.', + 'Macías-Pérez, J. F.', + 'Mauskopf, P.', + 'Maury, A.', + 'Mayet, F.', + 'Monfardini, A.', + 'Perotto, L.', + 'Pisano, G.', + 'Ponthieu, N.', + 'Revéret, V.', + 'Romero, C.', + 'Roussel, H.', + 'Ruppin, F.', + 'Schuster, K.', + 'Shimajiri, Y.', + 'Shu, S.', + 'Sievers, A.', + 'Tucker, C.', + 'Zylka, R.', + ], + }, + { + title: + 'Analysis of Galactic molecular cloud polarization maps: a review of the methods', + bibcode: '2020EPJWC.22800019P', + author: ['Poidevin, Frédérick'], + }, + { + title: + 'GASTON: Galactic Star Formation with NIKA2 A new population of cold massive sources discovered', + bibcode: '2020EPJWC.22800018P', + author: [ + 'Peretto, N.', + 'Rigby, A.', + 'Adam, R.', + 'Ade, P.', + 'André, P.', + 'Andrianasolo, A.', + 'Aussel, H.', + 'Bacmann, A.', + 'Beelen, A.', + 'Benoît, A.', + 'Bideaud, A.', + 'Bourrion, O.', + 'Calvo, M.', + 'Catalano, A.', + 'Comis, B.', + 'De Petris, M.', + 'Désert, F. -X.', + 'Doyle, S.', + 'Driessen, E. F. C.', + 'Gomez, A.', + 'Goupy, J.', + 'Kéruzoré, F.', + 'Kramer, C.', + 'Ladjelate, B.', + 'Lagache, G.', + 'Leclercq, S.', + 'Lestrade, J. -F.', + 'Macías-Pérez, J. F.', + 'Mauskopf, P.', + 'Mayet, F.', + 'Monfardini, A.', + 'Motte, F.', + 'Perotto, L.', + 'Pisano, G.', + 'Ponthieu, N.', + 'Revéret, V.', + 'Ristorcelli, I.', + 'Ritacco, A.', + 'Romero, C.', + 'Roussel, H.', + 'Ruppin, F.', + 'Schuster, K.', + 'Shu, S.', + 'Sievers, A.', + 'Tucker, C.', + 'Zylka, R.', + ], + }, + { + title: 'Debris disks around stars in the NIKA2 era', + bibcode: '2020EPJWC.22800015L', + author: [ + 'Lestrade, J. -F.', + 'Augereau, J. -C.', + 'Booth, M.', + 'Adam, R.', + 'Ade, P.', + 'André, P.', + 'Andrianasolo, A.', + 'Aussel, H.', + 'Beelen, A.', + 'Benoît, A.', + 'Bideaud, A.', + 'Bourrion, O.', + 'Calvo, M.', + 'Catalano, A.', + 'Comis, B.', + 'De Petris, M.', + 'Désert, F. -X.', + 'Doyle, S.', + 'Driessen, E. F. C.', + 'Gomez, A.', + 'Goupy, J.', + 'Holland, W.', + 'Kéruzoré, F.', + 'Kramer, C.', + 'Ladjelate, B.', + 'Lagache, G.', + 'Leclercq, S.', + 'Lefèvre, C.', + 'Macías-Pérez, J. F.', + 'Mauskopf, P.', + 'Mayet, F.', + 'Monfardini, A.', + 'Perotto, L.', + 'Pisano, G.', + 'Ponthieu, N.', + 'Revéret, V.', + 'Ritacco, A.', + 'Romero, C.', + 'Roussel, H.', + 'Ruppin, F.', + 'Schuster, K.', + 'Shu, S.', + 'Sievers, A.', + 'Thébault, P.', + 'Tucker, C.', + 'Zylka, R.', + ], + }, + { + title: 'NOEMA complementarity with NIKA2', + bibcode: '2020EPJWC.22800014L', + author: [ + 'Lefèvre, Charlène', + 'Kramer, Carsten', + 'Neri, Roberto', + 'Berta, Stefano', + 'Schuster, Karl', + ], + }, + { + title: 'Dust evolution in pre-stellar cores', + bibcode: '2020EPJWC.22800013L', + author: [ + 'Lefèvre, Charlène', + 'Pagani, Laurent', + 'Ladjelate, Bilal', + 'Min, Michiel', + 'Hirashita, Hiroyuki', + 'Zylka, Robert', + ], + }, + { + title: + 'Preliminary results on the instrumental polarization of NIKA2-Pol at the IRAM 30m telescope', + bibcode: '2020EPJWC.22800002A', + author: [ + 'Ajeddig, H.', + 'Adam, R.', + 'Ade, P.', + 'André, Ph.', + 'Andrianasolo, A.', + 'Aussel, H.', + 'Beelen, A.', + 'Benoît, A.', + 'Bideaud, A.', + 'Bourrion, O.', + 'Calvo, M.', + 'Catalano, A.', + 'Comis, B.', + 'De Petris, M.', + 'Désert, F. -X.', + 'Doyle, S.', + 'Driessen, E. F. C.', + 'Gomez, A.', + 'Goupy, J.', + 'Kéruzoré, F.', + 'Kramer, C.', + 'Ladjelate, B.', + 'Lagache, G.', + 'Leclercq, S.', + 'Lestrade, J. -F.', + 'Macías-Pérez, J. F.', + 'Maury, A.', + 'Mauskopf, P.', + 'Mayet, F.', + 'Monfardini, A.', + 'Perotto, L.', + 'Pisano, G.', + 'Ponthieu, N.', + 'Revéret, V.', + 'Ritacco, A.', + 'Romero, C.', + 'Roussel, H.', + 'Ruppin, F.', + 'Schuster, K.', + 'Shimajiri, Y.', + 'Shu, S.', + 'Sievers, A.', + 'Tucker, C.', + 'Zylka, R.', + ], + }, + { + title: + 'Preliminary results for the 19F(ρ,α)16O reaction cross section measured at INFN-LNS', + bibcode: '2020EPJWC.22702009P', + author: [ + 'Petruse, T.', + 'Guardo, G. L.', + 'Cognata, M. La', + 'Lattuada, D.', + 'Spitalieri, C.', + 'Balabanski, D. L.', + 'Agiksoz, E.', + 'Acosta, L.', + 'Capponi, L.', + 'Carbone, D.', + 'Cherubini, S.', + 'Choudhury, D.', + "D'Agata, G.", + 'Pietro, A. Di', + 'Figuera, P.', + 'Gulino, M.', + 'Kilik, A. I.', + 'Commara, M. La', + 'Lamia, L.', + 'Matei, C.', + 'Palmerini, S.', + 'Pizzone, R. G.', + 'Romano, S.', + 'Soderstrom, P. -A.', + 'Sparta, R.', + 'Tumino, A.', + 'Onses, S. Vinales', + ], + }, + { + title: + 'Study of the neutron induced reaction 17O(n,α)14C at astrophysical energies via the Trojan Horse Method', + bibcode: '2020EPJWC.22702007O', + author: [ + 'Oliva, A. A.', + 'Lamia, L.', + 'Guardo, G. L.', + 'Spitaleri, C.', + 'Cherubini, S.', + 'Cvetinovic, A.', + "D'Agata, G.", + 'de Sereville, N.', + 'Pietro, A. Di', + 'Figuera, P.', + 'Gulino, M.', + 'Hammache, F.', + 'Hayakawa, S.', + 'Indelicato, I.', + 'Cognata, M. La', + 'Commara, M. La', + 'Lattuada, D.', + 'Lattuada, M.', + 'Manico, G.', + 'Mazzocco, M.', + 'Messina, S.', + 'Palmerini, S.', + 'Pizzone, R. G.', + 'Pumo, M. L.', + 'Rapisarda, G. G.', + 'Romano, S.', + 'Sergi, M. L.', + 'Soic, N.', + 'Spartà, R.', + 'Tumino, A.', + ], + }, + { + title: + 'Nuclear β-decays in plasmas: how to correlate plasma density and temperature to the activity', + bibcode: '2020EPJWC.22702006N', + author: [ + 'Naselli, Eugenia', + 'Mascali, David', + 'Caliri, Claudia', + 'Castro, Giuseppe', + 'Celona, Luigi', + 'Galatá, Alessio', + 'Gammino, Santo', + 'Mazzaglia, Maria', + 'Romano, Francesco Paolo', + 'Giuseppe, Torrisi', + 'Santonocito, Domenico', + 'Cosentino, Gianluigi', + 'Amaducci, Simone', + ], + }, + { + title: + 'Study of the 22Ne(α , γ)26Mg reaction at LUNA', + bibcode: '2020EPJWC.22702004M', + author: ['Masha, Eliana'], + }, + { + title: + 'Dispersion (asymptotic) theory of charged-particle transfer reactions and nuclear astrophysics', + bibcode: '2020EPJWC.22701019Y', + author: ['Yarmukhamedov, R.', 'Tursunmakhatov, K. I.', 'Igamov, S. B.'], + }, + { + title: 'Short introduction to the physics of neutron stars', + bibcode: '2020EPJWC.22701018V', + author: ['Vidaña, Isaac'], + }, + { + title: + 'Underground Nuclear Astrophysics: pushing direct measurements toward the Gamow window', + bibcode: '2020EPJWC.22701015P', + author: ['Prati, Paolo'], + }, + { + title: + 'The PANDORA project: an experimental setup for measuring in-plasma β-decays of astrophysical interest', + bibcode: '2020EPJWC.22701013M', + author: [ + 'Mascali, David', + 'Busso, Maurizio', + 'Mengoni, Alberto', + 'Amaducci, Simone', + 'Giuseppe, Castro', + 'Celona, Luigi', + 'Cosentino, Gianluigi', + 'Cristallo, Sergio', + 'Finocchiaro, Paolo', + 'Galata, Alessio', + 'Gammino, Santo', + 'Massimi, Cristian', + 'Maggiore, Mario', + 'Mauro, Giorgio', + 'Maria, Mazzaglia', + 'Naselli, Eugenia', + 'Odorici, Fabrizio', + 'Palmerini, Sara', + 'Santonocito, Domenico', + 'Giuseppe, Torrisi', + ], + }, + { + title: + 'Resonant reactions of astrophysical interest studied by means of the Trojan Horse Method. Two case studies', + bibcode: '2020EPJWC.22701011L', + author: [ + 'La Cognata, Marco', + 'Spitaleri, Claudio', + 'Cherubini, Silvio', + 'Gulino, Marisa', + 'Lamia, Livio', + 'Pizzone, Rosario G.', + 'Romano, Stefano', + 'Tumino, Aurora', + ], + }, + ]; + + const Paper = ({ title, bibcode, author }) => { + return ( +
  • + {title} +
      + {author.slice(0, 3).map((entry, i) => ( +
    • {`${entry}${i < 2 ? ';' : ''}`}
    • + ))} + {author.length > 3 &&
    • ...
    • } +
    +
  • + ); + }; + Paper.defaultProps = { + title: '', + bibcode: '', + author: [], + }; + + Paper.propTypes = { + title: PropTypes.string, + bibcode: PropTypes.string, + author: PropTypes.arrayOf(PropTypes.string), + }; + + const selector = (state) => { + return { + getRecommendationsRequest: state.requests.GET_RECOMMENDATIONS, + }; + }; + + const RecommendedList = () => { + const dispatch = useDispatch(); + const { getRecommendationsRequest } = useSelector(selector); + React.useEffect(() => { + console.log('getting recommendations'); + dispatch( + getRecommendations({ + function: 'similar', + sort: 'entry_date', + numDocs: 5, + cutoffDays: 5, + topNReads: 10, + }) + ); + }, []); + + console.log(getRecommendationsRequest); + + if (getRecommendationsRequest.status === 'pending') { + return ( +
    + +