final sitemap I think
This commit is contained in:
parent
8744fb6acf
commit
59c1ec058c
9 changed files with 109863 additions and 26 deletions
|
@ -25,7 +25,7 @@ SITEMAP_ALLOWED_HOST="https://api.example.com"
|
||||||
|
|
||||||
## THESE VARIABLES ARE FOR SIMPLE-PAYMENT-GATEWAY APP
|
## THESE VARIABLES ARE FOR SIMPLE-PAYMENT-GATEWAY APP
|
||||||
#To see all possible options, check simple-payment-gateway/src/app:GatewayTypes
|
#To see all possible options, check simple-payment-gateway/src/app:GatewayTypes
|
||||||
ACTIVE_GATEWAYS="cod,cash,transfer"
|
ACTIVE_PAYMENT_METHODS="cod,cash,transfer"
|
||||||
# only Sk,En available :). Determines what language the gateway names will be in storefront
|
# only Sk,En available :). Determines what language the gateway names will be in storefront
|
||||||
LOCALE="Sk"
|
LOCALE="Sk"
|
||||||
# uses https://crates.io/crates/iso_currency
|
# uses https://crates.io/crates/iso_currency
|
||||||
|
|
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -3377,7 +3377,7 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "saleor-app-sdk"
|
name = "saleor-app-sdk"
|
||||||
version = "0.2.3"
|
version = "0.2.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -3885,7 +3885,6 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tinytemplate",
|
"tinytemplate",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
|
@ -31,8 +31,8 @@ dependencies = [
|
||||||
[tasks.push-containers]
|
[tasks.push-containers]
|
||||||
workspace = false
|
workspace = false
|
||||||
script = '''
|
script = '''
|
||||||
docker push ghcr.io/djkato/saleor-sitemap-generator:latest
|
docker push ghcr.io/djkato/saleor-app-sitemap-generator:latest
|
||||||
docker push ghcr.io/djkato/saleor-simple-payment-gateway:latest
|
docker push ghcr.io/djkato/saleor-app-simple-payment-gateway:latest
|
||||||
'''
|
'''
|
||||||
|
|
||||||
[tasks.delete-images]
|
[tasks.delete-images]
|
||||||
|
|
1
sitemap-generator/db.cbor
Normal file
1
sitemap-generator/db.cbor
Normal file
File diff suppressed because one or more lines are too long
109799
sitemap-generator/db.json
Normal file
109799
sitemap-generator/db.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,6 @@ use std::{
|
||||||
fs::{self},
|
fs::{self},
|
||||||
io::ErrorKind,
|
io::ErrorKind,
|
||||||
};
|
};
|
||||||
use tinytemplate::TinyTemplate;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{AppState, SitemapConfig},
|
app::{AppState, SitemapConfig},
|
||||||
|
@ -316,12 +315,8 @@ async fn update_or_create<T: Serialize + Clone>(
|
||||||
for affected in affected_urls.iter_mut() {
|
for affected in affected_urls.iter_mut() {
|
||||||
match affected {
|
match affected {
|
||||||
AffectedType::Data(url) => {
|
AffectedType::Data(url) => {
|
||||||
match Url::new(
|
match Url::new(data.clone(), sitemap_config, item.clone(), rel_item.clone())
|
||||||
data.clone(),
|
{
|
||||||
&sitemap_config,
|
|
||||||
item.clone(),
|
|
||||||
rel_item.clone(),
|
|
||||||
) {
|
|
||||||
Ok(new_url) => {
|
Ok(new_url) => {
|
||||||
url.url = new_url.url;
|
url.url = new_url.url;
|
||||||
url.data = new_url.data;
|
url.data = new_url.data;
|
||||||
|
@ -338,7 +333,7 @@ async fn update_or_create<T: Serialize + Clone>(
|
||||||
let new_data: ProductCreated = url.clone().into();
|
let new_data: ProductCreated = url.clone().into();
|
||||||
match Url::new(
|
match Url::new(
|
||||||
new_data,
|
new_data,
|
||||||
&sitemap_config,
|
sitemap_config,
|
||||||
url.clone().data,
|
url.clone().data,
|
||||||
Some(item.clone()),
|
Some(item.clone()),
|
||||||
) {
|
) {
|
||||||
|
@ -354,7 +349,7 @@ async fn update_or_create<T: Serialize + Clone>(
|
||||||
let new_data: CollectionCreated = url.clone().into();
|
let new_data: CollectionCreated = url.clone().into();
|
||||||
match Url::new(
|
match Url::new(
|
||||||
new_data,
|
new_data,
|
||||||
&sitemap_config,
|
sitemap_config,
|
||||||
url.clone().data,
|
url.clone().data,
|
||||||
Some(item.clone()),
|
Some(item.clone()),
|
||||||
) {
|
) {
|
||||||
|
@ -370,7 +365,7 @@ async fn update_or_create<T: Serialize + Clone>(
|
||||||
let new_data: PageCreated = url.clone().into();
|
let new_data: PageCreated = url.clone().into();
|
||||||
match Url::new(
|
match Url::new(
|
||||||
new_data,
|
new_data,
|
||||||
&sitemap_config,
|
sitemap_config,
|
||||||
url.clone().data,
|
url.clone().data,
|
||||||
Some(item.clone()),
|
Some(item.clone()),
|
||||||
) {
|
) {
|
||||||
|
@ -386,7 +381,7 @@ async fn update_or_create<T: Serialize + Clone>(
|
||||||
let new_data: CollectionCreated = url.clone().into();
|
let new_data: CollectionCreated = url.clone().into();
|
||||||
match Url::new(
|
match Url::new(
|
||||||
new_data,
|
new_data,
|
||||||
&sitemap_config,
|
sitemap_config,
|
||||||
url.clone().data,
|
url.clone().data,
|
||||||
Some(item.clone()),
|
Some(item.clone()),
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -155,7 +155,11 @@ pub async fn regenerate(state: AppState, saleor_api_url: String) -> anyhow::Resu
|
||||||
slug: p.slug.clone(),
|
slug: p.slug.clone(),
|
||||||
typ: ItemType::Product,
|
typ: ItemType::Product,
|
||||||
},
|
},
|
||||||
None,
|
p.category.clone().map(|c| ItemData {
|
||||||
|
id: c.id.inner().to_owned(),
|
||||||
|
slug: c.slug,
|
||||||
|
typ: ItemType::Category,
|
||||||
|
}),
|
||||||
) {
|
) {
|
||||||
Ok(u) => Some(u),
|
Ok(u) => Some(u),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -4,8 +4,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
create_app,
|
create_app,
|
||||||
queries::event_subjects_updated::{Category, Product, ProductUpdated},
|
sitemap::{ItemType, UrlSet},
|
||||||
sitemap::{ItemType, Url, UrlSet},
|
|
||||||
};
|
};
|
||||||
use async_std::task::sleep;
|
use async_std::task::sleep;
|
||||||
use axum::{
|
use axum::{
|
||||||
|
@ -61,11 +60,12 @@ pub async fn app_runs_and_responses() {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[traced_test]
|
#[traced_test]
|
||||||
#[serial]
|
#[serial]
|
||||||
|
//TODO: This test is busted or smt
|
||||||
async fn update_event_updates_correctly() {
|
async fn update_event_updates_correctly() {
|
||||||
let mut app = init_test_app().await;
|
let mut app = init_test_app().await;
|
||||||
let (_, sitemap_config) = testing_configs();
|
let (_, sitemap_config) = testing_configs();
|
||||||
|
|
||||||
let mut evn = gen_random_url_set(50, &sitemap_config);
|
let mut evn = gen_random_url_set(500, &sitemap_config);
|
||||||
for (body, _, webhook_type) in evn.clone() {
|
for (body, _, webhook_type) in evn.clone() {
|
||||||
app = create_query(app, body, webhook_type).await;
|
app = create_query(app, body, webhook_type).await;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,22 @@ fn urlset_serialisation_isnt_lossy() {
|
||||||
let deserialized_url_set: UrlSet = serde_cbor::de::from_slice(&file_str).unwrap();
|
let deserialized_url_set: UrlSet = serde_cbor::de::from_slice(&file_str).unwrap();
|
||||||
assert_eq!(url_set, deserialized_url_set);
|
assert_eq!(url_set, deserialized_url_set);
|
||||||
}
|
}
|
||||||
//TODO: TEST UPDATES AND DELETES, UPDATING URL CREATES A NEW ENTRY INSTEAD OF EDITING PREVIOUS ONE
|
|
||||||
|
// #[rstest]
|
||||||
|
// #[traced_test]
|
||||||
|
// #[parallel]
|
||||||
|
// fn desereialize_cbor() {
|
||||||
|
// std::fs::write(
|
||||||
|
// "db.json",
|
||||||
|
// serde_json::to_string_pretty(
|
||||||
|
// &serde_cbor::de::from_slice::<UrlSet>(&std::fs::read("db.cbor").unwrap()).unwrap(),
|
||||||
|
// )
|
||||||
|
// .unwrap(),
|
||||||
|
// )
|
||||||
|
// .unwrap();
|
||||||
|
//
|
||||||
|
// // assert_eq!(url_set, deserialized_url_set);
|
||||||
|
// }
|
||||||
|
|
||||||
// #[rstest]
|
// #[rstest]
|
||||||
// #[traced_test]
|
// #[traced_test]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use axum::{
|
use axum::{
|
||||||
body::Body,
|
body::Body,
|
||||||
http::{Request, Response, StatusCode},
|
http::{Request, StatusCode},
|
||||||
routing::RouterIntoService,
|
routing::RouterIntoService,
|
||||||
};
|
};
|
||||||
use rand::{
|
use rand::{
|
||||||
|
@ -261,11 +261,35 @@ pub fn gen_random_url_set(
|
||||||
) -> Vec<(String, Url, EitherWebhookType)> {
|
) -> Vec<(String, Url, EitherWebhookType)> {
|
||||||
let mut res: Vec<(String, Url, EitherWebhookType)> = vec![];
|
let mut res: Vec<(String, Url, EitherWebhookType)> = vec![];
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
let slug = random_word::gen(random_word::Lang::En).to_owned();
|
let slug = random_word::gen(random_word::Lang::En).to_owned()
|
||||||
let id = cynic::Id::new(slug.to_owned() + "_ID");
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En);
|
||||||
|
let id = cynic::Id::new("ID_".to_owned() + &slug.clone());
|
||||||
|
|
||||||
let mut rel_slug = random_word::gen(random_word::Lang::En).to_owned();
|
let mut rel_slug = random_word::gen(random_word::Lang::En).to_owned()
|
||||||
let mut rel_id = cynic::Id::new(rel_slug.to_owned() + "_ID");
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En)
|
||||||
|
+ "_"
|
||||||
|
+ random_word::gen(random_word::Lang::En);
|
||||||
|
let mut rel_id = cynic::Id::new("ID_".to_owned() + &rel_slug.clone());
|
||||||
|
|
||||||
match rand::random::<ItemType>() {
|
match rand::random::<ItemType>() {
|
||||||
ItemType::Product => {
|
ItemType::Product => {
|
||||||
|
|
Loading…
Reference in a new issue