Project

General

Profile

« Previous | Next » 

Revision 48517

search/find: do not query for results if count returns 0

View differences:

modules/uoa-services-portal/trunk/portal-2/src/app/utils/fetchEntitiesClasses/fetchDataproviders.class.ts
100 100
          data => {
101 101
              this.searchUtils.totalResults = data;
102 102
              this.searchUtils.status = errorCodes.DONE;
103

  
104
              if(this.searchUtils.totalResults == 0) {
105
                this.searchUtils.status = errorCodes.NONE;
106
              }
103 107
          },
104 108
          err => {
105 109
              console.log(err);
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/find/search.component.ts
336 336
  }
337 337
  public searchPublications() {
338 338
    this.activeTab = "publications";
339
    if(this.reloadPublications) {
340
        this.reloadPublications = false;
341
        this.fetchPublications.getResultsByKeyword(this.keyword,  1, 10);
342
        this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword="  + this.keyword;
339
    if( this.reloadPublications &&
340
        this.fetchPublications.searchUtils.status != this.errorCodes.NONE &&
341
        this.fetchPublications.searchUtils.status != this.errorCodes.ERROR) {
342
      this.reloadPublications = false;
343
      this.fetchPublications.getResultsByKeyword(this.keyword,  1, 10);
344
      this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword="  + this.keyword;
343 345
    }
344 346
   }
345 347
   public searchDatasets() {
346 348
     this.activeTab = "datasets";
347
     if(this.reloadDatasets) {
348
         this.reloadDatasets = false;
349
         this.fetchDatasets.getResultsByKeyword(this.keyword,  1, 10);
350
         this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword="  + this.keyword;
349
     if(this.reloadDatasets &&
350
        this.fetchDatasets.searchUtils.status != this.errorCodes.NONE &&
351
        this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR) {
352
       this.reloadDatasets = false;
353
       this.fetchDatasets.getResultsByKeyword(this.keyword,  1, 10);
354
       this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword="  + this.keyword;
351 355
     }
352 356
   }
353 357
   public  searchProjects() {
354 358
     this.activeTab = "projects";
355
     if(this.reloadProjects) {
356
         this.reloadProjects = false;
357
         this.fetchProjects.getResultsByKeyword(this.keyword,  1, 10);
358
         this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects();// + "?keyword="  + this.keyword;
359
     if(this.reloadProjects &&
360
        this.fetchProjects.searchUtils.status != this.errorCodes.NONE &&
361
        this.fetchProjects.searchUtils.status != this.errorCodes.ERROR) {
362
       this.reloadProjects = false;
363
       this.fetchProjects.getResultsByKeyword(this.keyword,  1, 10);
364
       this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects();// + "?keyword="  + this.keyword;
359 365
     }
360 366
   }
361 367
   public  searchDataProviders() {
362 368
     this.activeTab = "dataproviders";
363
     if(this.reloadDataproviders) {
364
         this.reloadDataproviders = false;
365
         this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10);
366
         this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword="  + this.keyword;
369
     if( this.reloadDataproviders &&
370
         this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE &&
371
         this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR) {
372
       this.reloadDataproviders = false;
373
       this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10);
374
       this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword="  + this.keyword;
367 375
     }
368 376
   }
369 377
   public searchOrganizations() {
370 378
     this.activeTab = "organizations";
371
     if(this.reloadOrganizations) {
372
         this.reloadOrganizations = false;
373
         this.fetchOrganizations.getResultsByKeyword(this.keyword,  1, 10);
374
         this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword="  + this.keyword;
379
     if( this.reloadOrganizations &&
380
         this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE &&
381
         this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR) {
382
       this.reloadOrganizations = false;
383
       this.fetchOrganizations.getResultsByKeyword(this.keyword,  1, 10);
384
       this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword="  + this.keyword;
375 385
     }
376 386
   }
377 387

  
......
404 414
   private count() {
405 415
     if(this.activeTab != "publications"){
406 416
      this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
417
      this.fetchPublications.results = [];
407 418
      this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe(
408 419
             data => {
409 420
                console.log("Count results: "+data);
410 421
                 this.fetchPublications.searchUtils.totalResults = data;
411 422
                 this.fetchPublications.searchUtils.status = this.errorCodes.DONE;
423
                 if(this.fetchPublications.searchUtils.totalResults == 0) {
424
                   this.fetchPublications.searchUtils.status = this.errorCodes.NONE;
425
                 }
412 426
             },
413 427
             err => {
414 428
       		    console.log(err);
......
418 432
    }
419 433
    if(this.activeTab != "datasets"){
420 434
       this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
435
       this.fetchDatasets.results = [];
421 436
       this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe(
422 437
             data => {
423 438
                 this.fetchDatasets.searchUtils.totalResults = data;
424 439
                 this.fetchDatasets.searchUtils.status = this.errorCodes.DONE;
440
                 if(this.fetchDatasets.searchUtils.totalResults == 0) {
441
                   this.fetchDatasets.searchUtils.status = this.errorCodes.NONE;
442
                 }
425 443
             },
426 444
             err => {
427 445
                 console.log(err);
......
431 449
    }
432 450
    if(this.activeTab != "projects"){
433 451
      this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
452
      this.fetchProjects.results = [];
434 453
      this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe(
435 454
             data => {
436 455
                 this.fetchProjects.searchUtils.totalResults = data;
437 456
                 this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
457
                 if(this.fetchProjects.searchUtils.totalResults == 0) {
458
                   this.fetchProjects.searchUtils.status = this.errorCodes.NONE;
459
                 }
438 460
             },
439 461
             err => {
440 462
                 console.log(err);
......
443 465
       );
444 466
     }
445 467
     if(this.activeTab != "dataproviders"){
468
       this.fetchDataproviders.results = [];
446 469
       this.fetchDataproviders.getNumForSearch(this.keyword);
447 470
     }
448 471
      if(this.activeTab != "organizations"){
449 472
       this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
473
       this.fetchOrganizations.results = [];
450 474
       this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe(
451 475
             data => {
452 476
                 this.fetchOrganizations.searchUtils.totalResults = data;
453 477
                 this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
454

  
478
                 if(this.fetchOrganizations.searchUtils.totalResults == 0) {
479
                   this.fetchOrganizations.searchUtils.status = this.errorCodes.NONE;
480
                 }
455 481
             },
456 482
             err => {
457 483
                 console.log(err);

Also available in: Unified diff