Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

feat: download and store Airtable images #2926

Merged
merged 38 commits into from
Jan 25, 2023

Conversation

eddybrando
Copy link
Collaborator

@eddybrando eddybrando commented Jan 20, 2023

Changes

This pull request addresses an issue caused by Airtable's recent change to make the URLs of attachments expire after a couple of hours. The problem was that the profile pictures for advocates were not being displayed.

As recommended by Airtable, we need to download the files during the API fetch and store them on our end so that they remain accessible.

Closes #2894

Implementation details

  • A new method "storeImage" was added to the "AirtableRecords" class to download the images and store them in the project.
  • The "getImage" methods for the advocates and events were adjusted to use the "storeImage" method.
  • Two new files called "static/images/advocates/downloaded/.gitkeep" and "static/images/events/downloaded/.gitkeep" were added to the project to keep the directories for the downloaded files in git.
  • Any necessary adjustments were made related to the async functions and Promises to ensure that they are working properly.
  • All tests were adjusted to ensure that the new functionality is working as expected and new tests were added for the "storeImage" method.

How to read this PR

  • You can start by reviewing the code of the "storeImages" method and its tests.
  • Then you can take a look at the changes in the "getImages" methods and the adjustments to the tests for the advocates and events records.

@eddybrando eddybrando linked an issue Jan 23, 2023 that may be closed by this pull request
Base automatically changed from feat/2906-get-airtable-fields-by-id to main January 23, 2023 16:16
Copy link
Contributor

@y4izus y4izus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks great for me Eddy! Thank you very much! I have only 4 comments/requests :D

hooks/airtable-conversion-utils.ts Outdated Show resolved Hide resolved
hooks/airtable-conversion-utils.ts Outdated Show resolved Hide resolved
hooks/advocate-conversion-utils.ts Outdated Show resolved Hide resolved
hooks/advocate-conversion-utils.ts Show resolved Hide resolved
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>
@y4izus y4izus merged commit bfeb93e into main Jan 25, 2023
@y4izus y4izus deleted the feat/2894-download-airtable-images branch January 25, 2023 13:40
y4izus added a commit that referenced this pull request Feb 1, 2023
* refactor: script setup in "advocates" components

* refactor: script setup in "blockbuster" components

* refactor: script setup in "ecosystem" components

* refactor: script setup in "events" components

* refactor: script setup in "global" components

* refactor: script setup in "landing" components

* refactor: script setup in "layouts" components

* feat: Use qiskit-banner web component (#2921)

* feat: use qiskit banner component

* feat: update qiskit banner component styles

* feat: update qiskit banner alignment

* fix: Broken links to ignis (#2930)

* refactor: script setup in "learn" components

* feat: Update unstable terminal commands (#2904)

* update unstable terminal commands

* update quick start install instructions

* feat: update code cell snippet

* Update components/landing/TheQiskitCapabilitiesSection/CodeCell.vue

Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>

* feat: refactor install instructions

* feat: refactor app links and logic

* feat: refactor instructions logic

Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* feat(airtable): remove hardcoded field names (#2913)

* feat: replace field names with field IDs

* feat: get field names from field IDs

* feat: set all field names

* refactor: reuse Airtable base ID

* feat: less console errors

* fix: replace hardcoded field name

* chore: move line of code

* feat: get all field names to perform operations

* refactor: reuse view

* chore: update fetched events data

* feat: get field names from IDs

* Revert "chore: update fetched events data"

This reverts commit 678d134.

* refactor: DRY getFieldName function

* refactor: DRY getAllFieldNames function

* docs: correct returns types syntax

* refactor: rewrite as class

* refactor: rewrite as class

* refactor: extend generic class AirtableRecord

* fix: lint issues

* fix(airtable): use correct views

* refactor(airtable): meaningful class names

* fix(airtable): use correct "type" field ID

* refactor(airtable): reuse "recordFields" property

* feat(airtable): make class method private

* style: shorter if statement

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: script setup in "metal" components

* refactor: script setup in "overview" components

* fix(site-wide): tab component styling (#2925)

* Add quantum circuits page (#2923)

* Add preview of new quantum circuits page
* Update name for lesson 4 (Entanglement in action)

* feat: download and store Airtable images (#2926)

* feat: replace field names with field IDs

* feat: get field names from field IDs

* feat: set all field names

* refactor: reuse Airtable base ID

* feat: less console errors

* fix: replace hardcoded field name

* chore: move line of code

* feat: get all field names to perform operations

* refactor: reuse view

* chore: update fetched events data

* feat: get field names from IDs

* Revert "chore: update fetched events data"

This reverts commit 678d134.

* refactor: DRY getFieldName function

* refactor: DRY getAllFieldNames function

* docs: correct returns types syntax

* refactor: rewrite as class

* refactor: rewrite as class

* refactor: extend generic class AirtableRecord

* fix: lint issues

* fix(airtable): use correct views

* refactor(airtable): meaningful class names

* fix(airtable): use correct "type" field ID

* feat(advocates): store images locally

* feat(events): store images locally

* feat(airtable): use record ID for image name

* feat(airtable): track directories for downloads

* fix(airtable): image public paths

* test(airtable): storeImage

* feat(airtable): remove files age check

* refactor(airtable): use ID from class property

* style: lint

* feat(airtable): handle axios errors & write files async

* style: one-liner

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: simplify store function

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: script setup in "ui" components

* feat(learn): Show Account Button in Learn Pages (#2931)

* Issue 2866 Show Account Button in Learn Page

* refactor: Reused default-max layout

* fix: restore the content of package-lock.json

* Shows the account button for all learning pages

---------

Co-authored-by: Maria Hernández <maria.hernandez.baeza@ibm.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* feat: adds photos downloaded from airtable to .gitignore (#2953)

* chore: add TODO

* chore: remove unused variable

* feat(data-table)): require "columns" prop

* chore(data-table): remove unused prop

* fix(data-table): require prop

* refactor(basic-link): simplify code

* chore: remove unused component

* style: camel case variable

* style: camel case variable

* style: computed method naming

* fix(capability-card): computed syntax

* refactor(metal): function names and syntax

* chore: remove unnecessary "void"

* feat(advocate-card): make props optional

* refactor(advocates): function syntax

* chore: add TODO to check functionality later

* feat: use "Script Setup" in pages (#2937)

* refactor: script setup in pages

* feat(blockbuster): remove page

* style: remove unnecessary type declaration

* Updates package-lock

---------

Co-authored-by: Randy <randytolentino@ibm.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>
Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Maria <89911196+mariacloehb@users.noreply.github.com>
Co-authored-by: Maria Hernández <maria.hernandez.baeza@ibm.com>
y4izus added a commit that referenced this pull request Feb 9, 2023
* refactor: script setup in "advocates" components

* refactor: script setup in "blockbuster" components

* refactor: script setup in "ecosystem" components

* refactor: script setup in "events" components

* refactor: script setup in "global" components

* refactor: script setup in "landing" components

* refactor: script setup in "layouts" components

* feat: Use qiskit-banner web component (#2921)

* feat: use qiskit banner component

* feat: update qiskit banner component styles

* feat: update qiskit banner alignment

* fix: Broken links to ignis (#2930)

* refactor: script setup in "learn" components

* feat: Update unstable terminal commands (#2904)

* update unstable terminal commands

* update quick start install instructions

* feat: update code cell snippet

* Update components/landing/TheQiskitCapabilitiesSection/CodeCell.vue

Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>

* feat: refactor install instructions

* feat: refactor app links and logic

* feat: refactor instructions logic

Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* feat(airtable): remove hardcoded field names (#2913)

* feat: replace field names with field IDs

* feat: get field names from field IDs

* feat: set all field names

* refactor: reuse Airtable base ID

* feat: less console errors

* fix: replace hardcoded field name

* chore: move line of code

* feat: get all field names to perform operations

* refactor: reuse view

* chore: update fetched events data

* feat: get field names from IDs

* Revert "chore: update fetched events data"

This reverts commit 678d134.

* refactor: DRY getFieldName function

* refactor: DRY getAllFieldNames function

* docs: correct returns types syntax

* refactor: rewrite as class

* refactor: rewrite as class

* refactor: extend generic class AirtableRecord

* fix: lint issues

* fix(airtable): use correct views

* refactor(airtable): meaningful class names

* fix(airtable): use correct "type" field ID

* refactor(airtable): reuse "recordFields" property

* feat(airtable): make class method private

* style: shorter if statement

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: script setup in "metal" components

* refactor: script setup in "overview" components

* fix(site-wide): tab component styling (#2925)

* Add quantum circuits page (#2923)

* Add preview of new quantum circuits page
* Update name for lesson 4 (Entanglement in action)

* feat: download and store Airtable images (#2926)

* feat: replace field names with field IDs

* feat: get field names from field IDs

* feat: set all field names

* refactor: reuse Airtable base ID

* feat: less console errors

* fix: replace hardcoded field name

* chore: move line of code

* feat: get all field names to perform operations

* refactor: reuse view

* chore: update fetched events data

* feat: get field names from IDs

* Revert "chore: update fetched events data"

This reverts commit 678d134.

* refactor: DRY getFieldName function

* refactor: DRY getAllFieldNames function

* docs: correct returns types syntax

* refactor: rewrite as class

* refactor: rewrite as class

* refactor: extend generic class AirtableRecord

* fix: lint issues

* fix(airtable): use correct views

* refactor(airtable): meaningful class names

* fix(airtable): use correct "type" field ID

* feat(advocates): store images locally

* feat(events): store images locally

* feat(airtable): use record ID for image name

* feat(airtable): track directories for downloads

* fix(airtable): image public paths

* test(airtable): storeImage

* feat(airtable): remove files age check

* refactor(airtable): use ID from class property

* style: lint

* feat(airtable): handle axios errors & write files async

* style: one-liner

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: simplify store function

Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* refactor: script setup in "ui" components

* feat(learn): Show Account Button in Learn Pages (#2931)

* Issue 2866 Show Account Button in Learn Page

* refactor: Reused default-max layout

* fix: restore the content of package-lock.json

* Shows the account button for all learning pages

---------

Co-authored-by: Maria Hernández <maria.hernandez.baeza@ibm.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>

* feat: adds photos downloaded from airtable to .gitignore (#2953)

* chore: add TODO

* chore: remove unused variable

* feat(data-table)): require "columns" prop

* chore(data-table): remove unused prop

* fix(data-table): require prop

* refactor(basic-link): simplify code

* chore: remove unused component

* style: camel case variable

* style: camel case variable

* style: computed method naming

* fix(capability-card): computed syntax

* refactor(metal): function names and syntax

* chore: remove unnecessary "void"

* feat(advocate-card): make props optional

* refactor(advocates): function syntax

* chore: add TODO to check functionality later

* feat: use "Script Setup" in pages (#2937)

* refactor: script setup in pages

* feat(blockbuster): remove page

* style: remove unnecessary type declaration

* Updates package-lock

---------

Co-authored-by: Randy <randytolentino@ibm.com>
Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com>
Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Maria <89911196+mariacloehb@users.noreply.github.com>
Co-authored-by: Maria Hernández <maria.hernandez.baeza@ibm.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Download and store advocate's photos from Airtable during build
2 participants