IFRCGo / go-api

MIT License
14 stars 6 forks source link

[PROD] Donor Responses #2219

Closed szabozoltan69 closed 2 weeks ago

szabozoltan69 commented 1 month ago

Issue

There are erroneously (and multiplied) shown Donor Response AppealDocuments in our database.

Let's choose an example: https://www.ifrc.org/appeals?appeal_code=MDRZM021 https://goadmin.ifrc.org/en/admin/api/appealdocument/?q=ZM021 https://go.ifrc.org/emergencies/6817/reports (bottom, at Appeal Documents (6)) https://go-api.ifrc.org/api/PublicSiteAppeals?Appealnumber=MDRZM021&Hidden=false Here we find only 4 ones, namely MDRZM021eu1, MDRZM021eu2, MDRZM021ea, MDRZM021OS

But, fortunately, on https://go-api.ifrc.org/Help/Api/GET-api-PublicSiteDonorResponses it turned out that we can use this (until now not used) endpoint also: https://go-api.ifrc.org/api/PublicSiteDonorResponses?AppealCode=MDRZM021

Here we find the searched one:

<ArrayOfPublicSiteDonorResponse>
  <PublicSiteDonorResponse>
    <APP_Name>Zambia - Cholera Outbreak</APP_Name>
    <AmountCHF>2944515.210000000000</AmountCHF>
    <AppealCode>MDRZM021</AppealCode>
    <BaseDirectory>https://www.ifrc.org/docs/appeals/active/</BaseDirectory>
    <BaseFileName>MDRZM021.pdf</BaseFileName>
    <OSR_Code>S1</OSR_Code>
    <OSR_sname>Region: Africa</OSR_sname>
    <Region>Africa</Region>
    <RegionShort>AF</RegionShort>
    <StartDate>2024-01-01T00:00:00</StartDate>
  </PublicSiteDonorResponse>
</ArrayOfPublicSiteDonorResponse>

From this we can get a nice url: https://www.ifrc.org/docs/appeals/active/MDRZM021.pdf Which is even more concise than the recently kept: https://go-api.ifrc.org/publicfile/download?path=/docs/appeals/Active/&name=MDRZM021.pdf

(The error that should be fixed (not mentioning the multiple and wrongly tagged entities) means that we avoid the recently used "/docs/appeals/Active/&name=MDRZM021.pdf" parts, e.g. in https://goadmin.ifrc.org/en/admin/api/appealdocument/11473/ – which is not crystal clear how could get into the database, manually or via an already nonexistent record of the old appealdoc go-api url – because that /docs.... is simply prepended by our go.ifrc.org domain name and this way results an erroneous URL.)

After using the PublicSiteDonorResponses go-api endpoint we can delete manually the wrongly showed ones.

szabozoltan69 commented 1 month ago

The wrong data were fixed manually, via removing the redundant 3 records and fixing the missing "www.ifrc.org" at the beginning of the 8 URL-s. (ID-s: 11469, 11472, 11473, 11474, 11475, 11489, 14553, 14554)

Recently the normal sync_appealdocs recreates these kind of erroneous entities.

szabozoltan69 commented 1 month ago

Deployed to Staging and (via cherry-pick) to Prod also.