From 5fa4a4061476679d00ad1149b37e21d18963ad4c Mon Sep 17 00:00:00 2001 From: Betsy Castro <5490820+betsyecastro@users.noreply.github.com> Date: Fri, 30 Sep 2022 14:26:33 -0500 Subject: [PATCH 01/46] Lists the publications from Academics Analytics in a modal in the publications edit view --- app/Http/Controllers/ProfilesController.php | 7 +- app/Profile.php | 83 +++++++++++++++++++ config/app.php | 4 + ..._import_academics_analytics_data.blade.php | 29 +++++++ .../views/profiles/edit/layout.blade.php | 2 + .../profiles/edit/publications.blade.php | 4 + 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 resources/views/profiles/edit/_import_academics_analytics_data.blade.php diff --git a/app/Http/Controllers/ProfilesController.php b/app/Http/Controllers/ProfilesController.php index 1bbc461f..93a89aba 100644 --- a/app/Http/Controllers/ProfilesController.php +++ b/app/Http/Controllers/ProfilesController.php @@ -238,6 +238,11 @@ public function edit(Profile $profile, $section) ->with('flash_message', 'Publications updated via ORCID.'); } + $publications = Cache::get('profile_publications', $profile->updateAcademicsAnalytics()); + + //Cache::tags(['profile_publications'])->add('profile_publications', $profile->updateAcademicsAnalytics(), 86400); + + $data = $profile->data()->$section()->get(); // if no data, include one item to use as a template @@ -248,7 +253,7 @@ public function edit(Profile $profile, $section) $data->push($record); } - return view('profiles.edit', compact('profile', 'section', 'data')); + return view('profiles.edit', compact('profile', 'section', 'data', 'publications')); } /** diff --git a/app/Profile.php b/app/Profile.php index 915284b2..5e8d8c73 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -195,6 +195,7 @@ public function updateORCID() } else if($ref['external-id-type'] == "doi"){ $url = "http://doi.org/" . $ref['external-id-value']; + $doi = $ref['external-id-value']; } } $record = ProfileData::firstOrCreate([ @@ -205,6 +206,7 @@ public function updateORCID() ],[ 'data' => [ 'url' => $url, + 'doi' => $doi, 'title' => $record['work-summary'][0]['title']['title']['value'], 'year' => $record['work-summary'][0]['publication-date']['year']['value'] ?? null, 'type' => ucwords(strtolower(str_replace('_', ' ', $record['work-summary'][0]['type']))), @@ -219,6 +221,87 @@ public function updateORCID() return true; } + /** + * Checks if this profile has publications managed by ORCID + * + * @return bool + * mhj + */ + public function hasAcademicsAnalyticsManagedPublications() + { + if ($this->relationLoaded('information')) { + return (bool) ($this->information->first()->data['academics_analytics_managed'] ?? false); + } + + return $this->information()->where('data->academics_analytics_managed', '1')->exists(); + } + + public function updateAcademicsAnalytics() + { + $academics_analytics_id = $this->information()->get(array('data'))->toArray()[0]['data']['academics_analytics_id']; + + if(is_null($academics_analytics_id)){ + //can't update if we don't know your ID + return false; + } + + $aa_url = "https://api.academicanalytics.com/person/$academics_analytics_id/articles"; + + $client = new Client(); + + $res = $client->get($aa_url, [ + 'headers' => [ + 'apikey' => "***REMOVED***",//config('ACADEMICS_ANALYTICS_KEY'), + 'Accept' => 'application/json' + ], + 'http_errors' => false, // don't throw exceptions for 4xx,5xx responses + ]); + + //an error of some sort + if($res->getStatusCode() != 200){ + return false; + } + + $datum = json_decode($res->getBody()->getContents(), true); + $current_publications_dois = $this->publications->pluck('data.doi')->filter()->values(); + $datum = collect($datum)->whereNotIn('DOI', $current_publications_dois); + $publications = collect(); + + foreach($datum as $key => $record){ + $url = NULL; + + if(isset($record['DOI'])) { + $doi = $record['DOI']; + $url = "http://doi.org/$doi"; + } + + + $record = ProfileData::firstOrNew([ + 'profile_id' => $this->id, + 'type' => 'publications', + 'data->doi' => $doi, + 'sort_order' => $record['ArticleYear'] ?? null, + ], [ + 'data' => [ + 'url' => $url, + 'title' => $record['ArticleTitle'], + 'doi' => $record['DOI'], + 'year' => $record['ArticleYear'] ?? null, + 'type' => "JOURNAL_ARTICLE", //ucwords(strtolower(str_replace('_', ' ', $record['work-summary'][0]['type']))), + 'status' => 'Published' + ], + ]); + + $publications->push($record); + } + + Cache::put('profile_publications', $publications, now()->addMinutes(40)); + + Cache::tags(['profile_data'])->flush(); + //¸¸ran through process successfully + return $publications; + } + public function updateDatum($section, $request) { $sort_order = count($request->data ?? []) + 1; diff --git a/config/app.php b/config/app.php index fe3b8316..c6aaa943 100644 --- a/config/app.php +++ b/config/app.php @@ -67,6 +67,9 @@ /** API response cache-control headers */ 'api_cache_control' => env('API_CACHE_CONTROL', 'public;no_cache;etag'), + /** ACADEMICS ANALYTICS API KEY */ + 'ACADEMICS_ANALYTICS_KEY' => env('ACADEMICS_ANALYTICS_KEY', false), + /* |-------------------------------------------------------------------------- | Application Debug Mode @@ -91,6 +94,7 @@ 'PUSHER_APP_KEY', 'PUSHER_APP_SECRET', 'AWS_SECRET', + 'ACADEMICS_ANALYTICS_KEY' ], '_SERVER' => [ 'APP_KEY', diff --git a/resources/views/profiles/edit/_import_academics_analytics_data.blade.php b/resources/views/profiles/edit/_import_academics_analytics_data.blade.php new file mode 100644 index 00000000..b4e1dbde --- /dev/null +++ b/resources/views/profiles/edit/_import_academics_analytics_data.blade.php @@ -0,0 +1,29 @@ +
+

We found some publications available for import from Academics Analytics. Click here to review your publications, check the entries that you would like to import, then click on the "Import" button.

+
+ + + \ No newline at end of file diff --git a/resources/views/profiles/edit/layout.blade.php b/resources/views/profiles/edit/layout.blade.php index 0c971312..1ce2f041 100644 --- a/resources/views/profiles/edit/layout.blade.php +++ b/resources/views/profiles/edit/layout.blade.php @@ -1,6 +1,8 @@

Edit {{ $profile->name }}'s @yield('section_name', ucfirst($section))

+@yield('academics_analitycs') + @yield('info') {!! Form::open(['url' => route('profiles.update', [$profile->slug, $section]), 'files' => $files ?? false]) !!} diff --git a/resources/views/profiles/edit/publications.blade.php b/resources/views/profiles/edit/publications.blade.php index 9ec8d4e2..a9a6806f 100644 --- a/resources/views/profiles/edit/publications.blade.php +++ b/resources/views/profiles/edit/publications.blade.php @@ -6,6 +6,10 @@ @include('profiles.edit._autosort_info') @endsection +@section('academics_analitycs') + @include('profiles.edit._import_academics_analytics_data') +@endsection + @section('form') @foreach ($data as $pub)
From 23f9482fed8e144dbfd26c46366faadc4ba7abfd Mon Sep 17 00:00:00 2001 From: Betsy Castro <5490820+betsyecastro@users.noreply.github.com> Date: Thu, 6 Oct 2022 13:53:57 -0500 Subject: [PATCH 02/46] Renders academics analytics publications in a modal through a livewire component when a button is clicked --- app/Http/Controllers/ProfilesController.php | 8 +---- .../AcademicsAnalyticsPublications.php | 31 ++++++++++++++++++ app/Profile.php | 16 +++------- ...academics-analytics-publications.blade.php | 20 ++++++++++++ ...ics_analytics_publications_modal.blade.php | 32 +++++++++++++++++++ .../profiles/edit/_autosort_info.blade.php | 7 ++++ ..._import_academics_analytics_data.blade.php | 29 ----------------- .../views/profiles/edit/layout.blade.php | 3 +- .../profiles/edit/publications.blade.php | 4 +-- 9 files changed, 99 insertions(+), 51 deletions(-) create mode 100644 app/Http/Livewire/AcademicsAnalyticsPublications.php create mode 100644 resources/views/livewire/academics-analytics-publications.blade.php create mode 100644 resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php delete mode 100644 resources/views/profiles/edit/_import_academics_analytics_data.blade.php diff --git a/app/Http/Controllers/ProfilesController.php b/app/Http/Controllers/ProfilesController.php index 93a89aba..56d30e70 100644 --- a/app/Http/Controllers/ProfilesController.php +++ b/app/Http/Controllers/ProfilesController.php @@ -237,12 +237,6 @@ public function edit(Profile $profile, $section) ->route('profiles.show', $profile->slug) ->with('flash_message', 'Publications updated via ORCID.'); } - - $publications = Cache::get('profile_publications', $profile->updateAcademicsAnalytics()); - - //Cache::tags(['profile_publications'])->add('profile_publications', $profile->updateAcademicsAnalytics(), 86400); - - $data = $profile->data()->$section()->get(); // if no data, include one item to use as a template @@ -253,7 +247,7 @@ public function edit(Profile $profile, $section) $data->push($record); } - return view('profiles.edit', compact('profile', 'section', 'data', 'publications')); + return view('profiles.edit', compact('profile', 'section', 'data')); } /** diff --git a/app/Http/Livewire/AcademicsAnalyticsPublications.php b/app/Http/Livewire/AcademicsAnalyticsPublications.php new file mode 100644 index 00000000..1066303e --- /dev/null +++ b/app/Http/Livewire/AcademicsAnalyticsPublications.php @@ -0,0 +1,31 @@ + 'loadPublications()']; + + public function mount() + { + //$this->modal_visible = true; + $this->publications = $this->profile->getAcademicsAnalyticsPublications(); + } + + public function render() + { + // dd($this->profile, $this->publications); + return view('livewire.academics-analytics-publications', [ + 'profile' => $this->profile, + //'modal_visible' => $this->modal_visible, + 'publications' => $this->publications, + ]); + } +} diff --git a/app/Profile.php b/app/Profile.php index 5e8d8c73..025eac7b 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -236,7 +236,7 @@ public function hasAcademicsAnalyticsManagedPublications() return $this->information()->where('data->academics_analytics_managed', '1')->exists(); } - public function updateAcademicsAnalytics() + public function getAcademicsAnalyticsPublications() { $academics_analytics_id = $this->information()->get(array('data'))->toArray()[0]['data']['academics_analytics_id']; @@ -264,7 +264,7 @@ public function updateAcademicsAnalytics() $datum = json_decode($res->getBody()->getContents(), true); $current_publications_dois = $this->publications->pluck('data.doi')->filter()->values(); - $datum = collect($datum)->whereNotIn('DOI', $current_publications_dois); + $datum = collect($datum )->whereNotIn('DOI', $current_publications_dois); $publications = collect(); foreach($datum as $key => $record){ @@ -278,11 +278,10 @@ public function updateAcademicsAnalytics() $record = ProfileData::firstOrNew([ 'profile_id' => $this->id, - 'type' => 'publications', - 'data->doi' => $doi, 'sort_order' => $record['ArticleYear'] ?? null, ], [ 'data' => [ + 'doi' => $doi, 'url' => $url, 'title' => $record['ArticleTitle'], 'doi' => $record['DOI'], @@ -291,15 +290,10 @@ public function updateAcademicsAnalytics() 'status' => 'Published' ], ]); - + $record->id = strval(rand(-100000, -1)); $publications->push($record); } - - Cache::put('profile_publications', $publications, now()->addMinutes(40)); - - Cache::tags(['profile_data'])->flush(); - //¸¸ran through process successfully - return $publications; + return $publications; } public function updateDatum($section, $request) diff --git a/resources/views/livewire/academics-analytics-publications.blade.php b/resources/views/livewire/academics-analytics-publications.blade.php new file mode 100644 index 00000000..a0604258 --- /dev/null +++ b/resources/views/livewire/academics-analytics-publications.blade.php @@ -0,0 +1,20 @@ + + @foreach ($publications as $pub) + + + + + + + + + + + + + + {{ $pub['data']['year'] }} + {{ $pub['data']['title'] }} + + @endforeach + \ No newline at end of file diff --git a/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php new file mode 100644 index 00000000..28c90ea1 --- /dev/null +++ b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php @@ -0,0 +1,32 @@ + + + diff --git a/resources/views/profiles/edit/_autosort_info.blade.php b/resources/views/profiles/edit/_autosort_info.blade.php index 0233fba3..2f1276ce 100644 --- a/resources/views/profiles/edit/_autosort_info.blade.php +++ b/resources/views/profiles/edit/_autosort_info.blade.php @@ -9,5 +9,12 @@ To manually sort all entries, leave the Year field empty (and include it as a part of @if(isset($suggestion)) {{ $suggestion }} @else another field @endisset instead). +
  • + To review your publications available for import from external sources use the buttons: +
    + +
  • diff --git a/resources/views/profiles/edit/_import_academics_analytics_data.blade.php b/resources/views/profiles/edit/_import_academics_analytics_data.blade.php deleted file mode 100644 index b4e1dbde..00000000 --- a/resources/views/profiles/edit/_import_academics_analytics_data.blade.php +++ /dev/null @@ -1,29 +0,0 @@ -
    -

    We found some publications available for import from Academics Analytics. Click here to review your publications, check the entries that you would like to import, then click on the "Import" button.

    -
    - - - \ No newline at end of file diff --git a/resources/views/profiles/edit/layout.blade.php b/resources/views/profiles/edit/layout.blade.php index 1ce2f041..4a370504 100644 --- a/resources/views/profiles/edit/layout.blade.php +++ b/resources/views/profiles/edit/layout.blade.php @@ -1,9 +1,8 @@

    Edit {{ $profile->name }}'s @yield('section_name', ucfirst($section))

    -@yield('academics_analitycs') - @yield('info') +@yield('academics_analytics_publications_modal') {!! Form::open(['url' => route('profiles.update', [$profile->slug, $section]), 'files' => $files ?? false]) !!} diff --git a/resources/views/profiles/edit/publications.blade.php b/resources/views/profiles/edit/publications.blade.php index a9a6806f..b956c3c8 100644 --- a/resources/views/profiles/edit/publications.blade.php +++ b/resources/views/profiles/edit/publications.blade.php @@ -6,8 +6,8 @@ @include('profiles.edit._autosort_info') @endsection -@section('academics_analitycs') - @include('profiles.edit._import_academics_analytics_data') +@section('academics_analytics_publications_modal') + @include('profiles.edit._academics_analytics_publications_modal') @endsection @section('form') From 1f2604a34657878ecbe84d34c9fa827267128e9d Mon Sep 17 00:00:00 2001 From: Betsy Castro <5490820+betsyecastro@users.noreply.github.com> Date: Fri, 7 Oct 2022 16:05:28 -0500 Subject: [PATCH 03/46] Adds pagination feature to publications listed on modal --- .../AcademicsAnalyticsPublications.php | 23 ++++---- app/Profile.php | 5 +- app/Providers/AppServiceProvider.php | 17 ++++++ ...academics-analytics-publications.blade.php | 54 ++++++++++++------- ...ics_analytics_publications_modal.blade.php | 19 ++----- .../views/profiles/edit/layout.blade.php | 1 + 6 files changed, 72 insertions(+), 47 deletions(-) diff --git a/app/Http/Livewire/AcademicsAnalyticsPublications.php b/app/Http/Livewire/AcademicsAnalyticsPublications.php index 1066303e..1267b5dd 100644 --- a/app/Http/Livewire/AcademicsAnalyticsPublications.php +++ b/app/Http/Livewire/AcademicsAnalyticsPublications.php @@ -3,29 +3,30 @@ namespace App\Http\Livewire; use Livewire\Component; +use Livewire\WithPagination; use App\Profile; class AcademicsAnalyticsPublications extends Component { - //public bool $modal_visible; - public Profile $profile; - public $publications; + use WithPagination; - protected $listeners = ['loadPublications' => 'loadPublications()']; + protected $paginationTheme = 'bootstrap'; + public Profile $profile; - public function mount() - { - //$this->modal_visible = true; - $this->publications = $this->profile->getAcademicsAnalyticsPublications(); + public function data() + { + $per_page = 10; + return $this->profile + ->getAcademicsAnalyticsPublications() + ->sortByDesc('sort_order') + ->paginate($per_page); } public function render() { - // dd($this->profile, $this->publications); return view('livewire.academics-analytics-publications', [ 'profile' => $this->profile, - //'modal_visible' => $this->modal_visible, - 'publications' => $this->publications, + 'publications' => $this->data(), ]); } } diff --git a/app/Profile.php b/app/Profile.php index 025eac7b..cb705a62 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -275,8 +275,7 @@ public function getAcademicsAnalyticsPublications() $url = "http://doi.org/$doi"; } - - $record = ProfileData::firstOrNew([ + $record = ProfileData::firstorNew([ 'profile_id' => $this->id, 'sort_order' => $record['ArticleYear'] ?? null, ], [ @@ -402,7 +401,7 @@ public function loadApiData() }]); } - /** + /** * Registers media conversions. * * @param Media|null $media diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5091b6af..1f233794 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,6 +5,8 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Blade; use Illuminate\Pagination\Paginator; +use Illuminate\Support\Collection; +use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\View; use App\Setting; use Collective\Html\FormFacade as Form; @@ -24,6 +26,21 @@ public function boot() Paginator::defaultView('vendor.pagination.default'); Paginator::defaultSimpleView('vendor.pagination.simple-default'); + Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') { + $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); + + return new LengthAwarePaginator( + $this->forPage($page, $perPage), + $total ?: $this->count(), + $perPage, + $page, + [ + 'path' => LengthAwarePaginator::resolveCurrentPath(), + 'pageName' => $pageName, + ] + ); + }); + Form::component('inlineErrors', 'errors.inline', ['field_name']); View::composer([ diff --git a/resources/views/livewire/academics-analytics-publications.blade.php b/resources/views/livewire/academics-analytics-publications.blade.php index a0604258..19a57302 100644 --- a/resources/views/livewire/academics-analytics-publications.blade.php +++ b/resources/views/livewire/academics-analytics-publications.blade.php @@ -1,20 +1,36 @@ - - @foreach ($publications as $pub) - - - - + \ No newline at end of file diff --git a/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php index 28c90ea1..e88eb6a1 100644 --- a/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php +++ b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php @@ -7,20 +7,11 @@ - - - + + + + + + + + @endif \ No newline at end of file diff --git a/resources/views/livewire/show-modal.blade.php b/resources/views/livewire/show-modal.blade.php new file mode 100644 index 00000000..f38251f0 --- /dev/null +++ b/resources/views/livewire/show-modal.blade.php @@ -0,0 +1,56 @@ +
    +@if($modalVisible) + + @endif +
    \ No newline at end of file diff --git a/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php index e88eb6a1..dc73b08f 100644 --- a/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php +++ b/resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php @@ -8,10 +8,8 @@ - - - + diff --git a/resources/views/profiles/edit/_publications_table.blade.php b/resources/views/profiles/edit/_publications_table.blade.php new file mode 100644 index 00000000..49d6e7bf --- /dev/null +++ b/resources/views/profiles/edit/_publications_table.blade.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/resources/views/profiles/edit/publications.blade.php b/resources/views/profiles/edit/publications.blade.php index b956c3c8..9ec8d4e2 100644 --- a/resources/views/profiles/edit/publications.blade.php +++ b/resources/views/profiles/edit/publications.blade.php @@ -6,10 +6,6 @@ @include('profiles.edit._autosort_info') @endsection -@section('academics_analytics_publications_modal') - @include('profiles.edit._academics_analytics_publications_modal') -@endsection - @section('form') @foreach ($data as $pub)
    From 1b9574c8de151b74238bc8894486db11a3451732 Mon Sep 17 00:00:00 2001 From: Wun Chiou Date: Thu, 13 Oct 2022 16:05:23 -0500 Subject: [PATCH 05/46] AA: rename from academics to academic --- .env.example | 2 + ....php => AcademicAnalyticsPublications.php} | 6 +- app/Profile.php | 20 +++---- config/app.php | 6 +- ...academic-analytics-publications.blade.php} | 8 +-- resources/views/livewire/show-modal.blade.php | 56 ------------------- ...ics_analytics_publications_modal.blade.php | 21 ------- .../profiles/edit/_autosort_info.blade.php | 2 +- .../edit/_publications_table.blade.php | 52 ----------------- .../views/profiles/edit/layout.blade.php | 2 - 10 files changed, 23 insertions(+), 152 deletions(-) rename app/Http/Livewire/{AcademicsAnalyticsPublications.php => AcademicAnalyticsPublications.php} (85%) rename resources/views/livewire/{academics-analytics-publications.blade.php => academic-analytics-publications.blade.php} (90%) delete mode 100644 resources/views/livewire/show-modal.blade.php delete mode 100644 resources/views/profiles/edit/_academics_analytics_publications_modal.blade.php delete mode 100644 resources/views/profiles/edit/_publications_table.blade.php diff --git a/.env.example b/.env.example index 7a05118b..da603ceb 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,8 @@ TESTING_MENU=true GOOGLE_ANALYTICS_ID= INFLUUENT_API_KEY= WOS_TOKEN= +ORCID_TOKEN= +ACADEMIC_ANALYTICS_KEY= DB_CONNECTION=mysql DB_HOST= diff --git a/app/Http/Livewire/AcademicsAnalyticsPublications.php b/app/Http/Livewire/AcademicAnalyticsPublications.php similarity index 85% rename from app/Http/Livewire/AcademicsAnalyticsPublications.php rename to app/Http/Livewire/AcademicAnalyticsPublications.php index 1e234e60..3e4107b3 100644 --- a/app/Http/Livewire/AcademicsAnalyticsPublications.php +++ b/app/Http/Livewire/AcademicAnalyticsPublications.php @@ -6,7 +6,7 @@ use Livewire\WithPagination; use App\Profile; -class AcademicsAnalyticsPublications extends Component +class AcademicAnalyticsPublications extends Component { use WithPagination; @@ -28,7 +28,7 @@ public function getPublications() { $per_page = 10; return $this->publications = $this->profile - ->getAcademicsAnalyticsPublications() + ->getAcademicAnalyticsPublications() ->sortByDesc('sort_order') ->paginate($per_page); } @@ -50,6 +50,6 @@ public function render() } - return view('livewire.academics-analytics-publications', $data); + return view('livewire.academic-analytics-publications', $data); } } diff --git a/app/Profile.php b/app/Profile.php index cb705a62..29a09efc 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -227,31 +227,31 @@ public function updateORCID() * @return bool * mhj */ - public function hasAcademicsAnalyticsManagedPublications() + public function hasAcademicAnalyticsManagedPublications() { if ($this->relationLoaded('information')) { - return (bool) ($this->information->first()->data['academics_analytics_managed'] ?? false); + return (bool) ($this->information->first()->data['academic_analytics_managed'] ?? false); } - return $this->information()->where('data->academics_analytics_managed', '1')->exists(); + return $this->information()->where('data->academic_analytics_managed', '1')->exists(); } - public function getAcademicsAnalyticsPublications() + public function getAcademicAnalyticsPublications() { - $academics_analytics_id = $this->information()->get(array('data'))->toArray()[0]['data']['academics_analytics_id']; - - if(is_null($academics_analytics_id)){ + $academic_analytics_id = $this->information->first()?->academic_analytics_id; + + if(is_null($academic_analytics_id)){ //can't update if we don't know your ID return false; } - $aa_url = "https://api.academicanalytics.com/person/$academics_analytics_id/articles"; + $aa_url = "https://api.academicanalytics.com/person/$academic_analytics_id/articles"; $client = new Client(); $res = $client->get($aa_url, [ 'headers' => [ - 'apikey' => "***REMOVED***",//config('ACADEMICS_ANALYTICS_KEY'), + 'apikey' => config('app.academic_analytics_key'), 'Accept' => 'application/json' ], 'http_errors' => false, // don't throw exceptions for 4xx,5xx responses @@ -289,7 +289,7 @@ public function getAcademicsAnalyticsPublications() 'status' => 'Published' ], ]); - $record->id = strval(rand(-100000, -1)); + // $record->id = strval(rand(-100000, -1)); $publications->push($record); } return $publications; diff --git a/config/app.php b/config/app.php index c6aaa943..7cfdd9c9 100644 --- a/config/app.php +++ b/config/app.php @@ -67,8 +67,8 @@ /** API response cache-control headers */ 'api_cache_control' => env('API_CACHE_CONTROL', 'public;no_cache;etag'), - /** ACADEMICS ANALYTICS API KEY */ - 'ACADEMICS_ANALYTICS_KEY' => env('ACADEMICS_ANALYTICS_KEY', false), + /** ACADEMIC ANALYTICS API KEY */ + 'academic_analytics_key' => env('ACADEMIC_ANALYTICS_KEY', false), /* |-------------------------------------------------------------------------- @@ -94,7 +94,7 @@ 'PUSHER_APP_KEY', 'PUSHER_APP_SECRET', 'AWS_SECRET', - 'ACADEMICS_ANALYTICS_KEY' + 'ACADEMIC_ANALYTICS_KEY' ], '_SERVER' => [ 'APP_KEY', diff --git a/resources/views/livewire/academics-analytics-publications.blade.php b/resources/views/livewire/academic-analytics-publications.blade.php similarity index 90% rename from resources/views/livewire/academics-analytics-publications.blade.php rename to resources/views/livewire/academic-analytics-publications.blade.php index e8916221..0160bfa7 100644 --- a/resources/views/livewire/academics-analytics-publications.blade.php +++ b/resources/views/livewire/academic-analytics-publications.blade.php @@ -1,14 +1,14 @@
    - @if($modalVisible) -