manual update product pipeline
parent
1ac158976e
commit
531da068de
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"category": "Shinnex",
|
||||
"name": "Produktpipeline aktualisieren",
|
||||
"globalInputs": [],
|
||||
"tasks": [
|
||||
{
|
||||
"name": "Produktpipeline aktualisieren",
|
||||
"onFinish": "next",
|
||||
"undoPossible": false,
|
||||
"repeatPossible": true,
|
||||
"scriptPath": "script.py",
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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}")
|
|
@ -310,3 +310,14 @@ func VoteProduct(c *fiber.Ctx) error {
|
|||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -94,9 +94,9 @@ func SetupRoutes(app *fiber.App) {
|
|||
cf.Get("/origins", requestAccessValidation, customerfeedback.GetCustomerFeedbackOrigins)
|
||||
|
||||
pp := v1.Group("/productpipeline")
|
||||
|
||||
pp.Get("/", productpipeline.GetProducts)
|
||||
pp.Post("/vote", productpipeline.VoteProduct)
|
||||
pp.Get("/update", requestAccessValidation, productpipeline.GetManualFetchProducts)
|
||||
|
||||
app.Static("/", config.Cfg.FolderPaths.PublicStatic)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue