manual update product pipeline

main
alex 2024-06-11 22:02:51 +02:00
parent 1ac158976e
commit 531da068de
5 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,15 @@
{
"category": "Shinnex",
"name": "Produktpipeline aktualisieren",
"globalInputs": [],
"tasks": [
{
"name": "Produktpipeline aktualisieren",
"onFinish": "next",
"undoPossible": false,
"repeatPossible": true,
"scriptPath": "script.py",
"parameters": []
}
]
}

View File

@ -0,0 +1,23 @@
import sys
import requests
try:
with open('../../secrets/admin-dashboard-api-key.txt') as f:
adminDashboardApiKey = f.read().strip() # `.strip()` to remove any extra whitespace or newlines
except FileNotFoundError:
sys.exit("Error: API key file not found.")
except Exception as e:
sys.exit(f"Error reading the API key file: {e}")
try:
res = requests.get("https://devdash.ex.umbach.dev/api/v1/productpipeline/update",
headers={"X-Api-key": adminDashboardApiKey})
res.raise_for_status() # Raises a HTTPError if the HTTP request returned an unsuccessful status code
except requests.exceptions.HTTPError as http_err:
sys.exit(f"HTTP error occurred: {http_err}") # HTTP error
except requests.exceptions.RequestException as err:
sys.exit(f"Error occurred: {err}") # Other errors
except Exception as e:
sys.exit(f"An unexpected error occurred: {e}")
print(f"Response text: {res.text}")

BIN
main

Binary file not shown.

View File

@ -310,3 +310,14 @@ func VoteProduct(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK) return c.SendStatus(fiber.StatusOK)
} }
// can be triggered by admin dashboard group task
func GetManualFetchProducts(c *fiber.Ctx) error {
logger.AddSystemLog(rslogger.LogTypeInfo, "Request for manual retrieval of Google Sheet products received")
if err := FetchGoogleSheets(); err != nil {
return c.SendStatus(fiber.StatusInternalServerError)
}
return c.SendStatus(fiber.StatusOK)
}

View File

@ -94,9 +94,9 @@ func SetupRoutes(app *fiber.App) {
cf.Get("/origins", requestAccessValidation, customerfeedback.GetCustomerFeedbackOrigins) cf.Get("/origins", requestAccessValidation, customerfeedback.GetCustomerFeedbackOrigins)
pp := v1.Group("/productpipeline") pp := v1.Group("/productpipeline")
pp.Get("/", productpipeline.GetProducts) pp.Get("/", productpipeline.GetProducts)
pp.Post("/vote", productpipeline.VoteProduct) pp.Post("/vote", productpipeline.VoteProduct)
pp.Get("/update", requestAccessValidation, productpipeline.GetManualFetchProducts)
app.Static("/", config.Cfg.FolderPaths.PublicStatic) app.Static("/", config.Cfg.FolderPaths.PublicStatic)
} }