Skip to content

Commit

Permalink
136 advanced search with geolocation filters sorting (#149)
Browse files Browse the repository at this point in the history
* advanced youtube video search configured

* advanced search is working

* add advance toggle; correct geosearch examples

* changelog entry

* add graphql docs
  • Loading branch information
longshuicy authored May 29, 2024
1 parent 8a5d9e4 commit cfed597
Show file tree
Hide file tree
Showing 63 changed files with 11,490 additions and 1,098 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- YouTube advanced search with temporal and geolocation filters [#136](https://github.com/ncsa/standalone-smm-smile/issues/136)

### Fixed
- YouTube search histogram switching interval [#143](https://github.com/ncsa/standalone-smm-smile/issues/143)
- Reddit auth checkbox not visible [#144](https://github.com/ncsa/standalone-smm-smile/issues/144)
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ You can find the deployed python code in [smm-analytics repository](https://open
- Set the environment variable ```GA_KEY``` and provide the value of your Google Analytics 4 key.

Please contact the **[SRTI lab](https://srtilab.techservices.illinois.edu/about/)** to request assistance on setting up the SMILE server.


#### Generate GraphQL Docs
1. Install `npm install -g @2fd/graphdoc`
2. Update package.json to include the following script:
```json
"graphdoc": {
"endpoint": "http://localhost:5050/graphql",
"output": "./public/graphql-doc/schema"
}
```
3. Run `graphdoc --force`
4 changes: 4 additions & 0 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"start": " forever app.js",
"docker-start": "node app.js"
},
"graphdoc": {
"endpoint": "http://localhost:5050/graphql",
"output": "./public/graphql-doc/schema"
},
"author": "Chen Wang <cwang138@illinois>",
"license": "MIT"
}
128 changes: 123 additions & 5 deletions www/public/bootstrap/js/customized/query_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function init(){
// customize advance dropdown
$('#dropdownButton').on('click',function(){
if ($("#searchbox").val() !== '' && $("#searchbox").val() !== undefined){
if (queryTerm !== "queryTweetV2" && queryTerm !== "queryYoutube"){
if (queryTerm !== "queryTweetV2"){
$(this).parent().toggleClass('open');
if ($(this).parent().attr('class') === 'dropdown dropdown-lg open'){
// disable search and enable advanced search
Expand All @@ -78,8 +78,7 @@ function init(){

// initialize the advanced panel
// escape doule quotation mark
var keyword = $("#searchbox").val();
var keyword = keyword.replace(/[\"]+/g, `\\"`);
var keyword = $("#searchbox").val().replace(/[\"]+/g, `\\"`);

parameters['tweet']['q:'] = keyword;
parameters['tweet']['fields'] = `\n\t\t\tid\n\t\t\tid_str\n\t\t\tcreated_at\n\t\t\ttext\n\t\t\tretweet_count`+
Expand Down Expand Up @@ -136,6 +135,16 @@ function init(){
parameters['psComment']['fields']=`\n\t\t\tcomment_author_name\n\t\t\tbody\n\t\t\tcomment_created\n\t\t\tid\n\t\t\tlink_id\n\t\t\tparent_id`+
`\n\t\t\tcomment_score\n\t\t\tsubreddit_display_name\n\t\t\tsubreddit_name_prefixed\n\t\t\tsubreddit_id`;

parameters['youtubeSearch']['q:'] = keyword;
parameters['youtubeSearch']['order:'] = "relevance";
parameters['youtubeSearch']['videoDuration:'] = "any";
parameters['youtubeSearch']['fields'] = "\n\t\t\tkind\n\t\t\tetag\n\t\t\tid{\n\t\t\t\tkind\n\t\t\t\tvideoId\n\t\t\t\tchannelId\n\t\t\t\tplaylistId\n\t\t\t}" +
"\n\t\t\tsnippet{\n\t\t\t\tpublishedAt\n\t\t\t\tchannelId\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\tdefault_thumbnails_url" +
"\n\t\t\t\tdefault_thumbnails_width\n\t\t\t\tdefault_thumbnails_height\n\t\t\t\tmedium_thumbnails_url\n\t\t\t\tmedium_thumbnails_width" +
"\n\t\t\t\tmedium_thumbnails_height\n\t\t\t\thigh_thumbnails_url\n\t\t\t\thigh_thumbnails_width\n\t\t\t\thigh_thumbnails_height" +
"\n\t\t\t\tstandard_thumbnails_url\n\t\t\t\tstandard_thumbnails_width\n\t\t\t\tstandard_thumbnails_height\n\t\t\t\tmaxres_thumbnails_url" +
"\n\t\t\t\tmaxres_thumbnails_width\n\t\t\t\thigh_thumbnails_height\n\t\t\t\tchannelTitle\n\t\t\t\tliveBroadcastContent\n\t\t\t}";

Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
}
Expand Down Expand Up @@ -839,7 +848,115 @@ function init(){
});

/*----------------------------------------------------- Youtube Search-------------------------------------------------------*/
// TODO implement advanced youtube search here
// count
$("#youtube-count").change(function(){
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
// order
$("input[name='ytOrder']").change(function(){
parameters['youtubeSearch']['order:'] = $(this).val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});

// duration
$("input[name='ytDuration']").change(function(){
parameters['youtubeSearch']['videoDuration:'] = $(this).val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});

// advanced
$("#ytFilters").change(function() {
if ($("#ytFilters").is(':checked')) {
$(".form-group.ytFilters").show();
$("#channelId").change(function () {
parameters['youtubeSearch']['channelId:'] = $(this).val();
Query = updateString(queryTerm, parameters);
$("#input").val(`{\n\n` + Query + `\n\n}`);
});
$("#regionCode").change(function () {
parameters['youtubeSearch']['regionCode:'] = $(this).val();
Query = updateString(queryTerm, parameters);
$("#input").val(`{\n\n` + Query + `\n\n}`);
});
$("#relevanceLanguage").change(function () {
parameters['youtubeSearch']['relevanceLanguage:'] = $(this).val();
Query = updateString(queryTerm, parameters);
$("#input").val(`{\n\n` + Query + `\n\n}`);
});
}
else{
$(".form-group.ytFilters").hide();
parameters['youtubeSearch']['channelId:'] = '';
parameters['youtubeSearch']['regionCode:'] = '';
parameters['youtubeSearch']['relevanceLanguage:'] = '';
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
if ( $('.dropdown.dropdown-lg.open').length ){
pushAdvancedDropdown('on');
}
}
});

// published range
$("#ytDateRange").change(function() {
if ($("#ytDateRange").is(':checked')) {
$(".form-group.ytDateRange").show();
$("#publishedAfter").change(function(){
let publishedAfter = new Date($("#publishedAfter").val());
parameters['youtubeSearch']['publishedAfter:'] = publishedAfter.toISOString();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
$("#publishedBefore").change(function(){
let publishedBefore = new Date($("#publishedBefore").val());
parameters['youtubeSearch']['publishedBefore:'] = publishedBefore.toISOString();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
}
else{
$(".form-group.ytDateRange").hide();
parameters['youtubeSearch']['publishedAfter:'] = '';
parameters['youtubeSearch']['publishedBefore:'] = '';
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
if ( $('.dropdown.dropdown-lg.open').length ){
pushAdvancedDropdown('on');
}
}
});


// location
$("#ytGeoSearch").change(function(){
if ($("#ytGeoSearch").is(':checked')) {
$(".form-group.ytGeoSearch").show();
$("#ytLocation").change(function(){
parameters['youtubeSearch']['location:'] = $("#ytLocation").val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
$("#ytLocationRadius").change(function(){
parameters['youtubeSearch']['locationRadius:'] = $("#ytLocationRadius").val();
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
});
}
else {
$(".form-group.ytGeoSearch").hide();
parameters['youtubeSearch']['location:'] = '';
parameters['youtubeSearch']['locationRadius:'] = '';
Query =updateString(queryTerm,parameters);
$("#input").val(`{\n\n` + Query +`\n\n}`);
if ( $('.dropdown.dropdown-lg.open').length ){
pushAdvancedDropdown('on');
}
}

});

/*----------------------set intervals--------------------------------------------*/
$('input[name=histogram-interval]').change(function(){
Expand Down Expand Up @@ -904,7 +1021,7 @@ function updateString(queryTerm, parameters){
else if (queryTerm === 'pushshiftComment'){
query = `\treddit{\n\t\tpushshiftComment(`+ constructQuery(parameters.psComment) + `\n\t\t}\n\t}`;
}
else if (queryTerm === 'youtubeSearch'){
else if (queryTerm === 'queryYoutube'){
query = `\tyoutube{\n\t\tsearch(${constructQuery(parameters.youtubeSearch)}\n\t\t}\n\t}`;
}

Expand Down Expand Up @@ -951,6 +1068,7 @@ function setDate(){
$("#until").attr('max', max);
}


function setHitogramInterval(freq){
var filename = $("#sn-filename").val();

Expand Down
9 changes: 7 additions & 2 deletions www/public/bootstrap/js/customized/query_submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function submitQuery(textareaID,filenameID, dryrun = false){
prefix = 'reddit-Historical-Comment';
params = parameters.psComment ;
pages = -999;
}else if (queryTerm === 'youtubeSearch'){
}else if (queryTerm === 'queryYoutube'){
prefix = 'youtube-Search';
params = parameters.youtubeSearch ;
pages = parseInt($("#youtube-count").val())/50;
Expand Down Expand Up @@ -66,7 +66,12 @@ function submitQuery(textareaID,filenameID, dryrun = false){
renderPreview(data.rendering, prefix);
$("#saveButton").removeAttr("disabled");
$("#save-result").show();
}

// close dropdown menu
$("#dropdownButton").parent().toggleClass('open');
$("#simple-search-btn").prop('disabled',false);
pushAdvancedDropdown('off');
}
},
error: function(jqXHR, exception){
$("#error").val(jqXHR.responseText);
Expand Down
Loading

0 comments on commit cfed597

Please sign in to comment.