Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
🎨 script for fjerning av under_arbeid felt
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Sep 30, 2022
1 parent a25ac17 commit 7c6c101
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 166 deletions.
29 changes: 11 additions & 18 deletions sanity/scripts/renameField.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,22 @@ const client = sanityClient.withConfig({
dataset: "production",
});

/** Script for å rename data-felt
/** Script for å gjøre diverse oppgaver på dataset. Endre linje 15 og 20 med ønsket config
* https://www.sanity.io/schemas/rename-a-field-across-documents-5cd6f5f0
* Husk å kjøre backup med sanity dataset export først!
* run: sanity exec scripts/renameField.js --with-user-token
*/

const fetchDocuments = () => client.fetch(`*[_type in [ "ds_component_page"]]`);
const fetchDocuments = () => client.fetch(`*[under_arbeid != null]`);

const buildPatches = (docs) =>
docs
.filter(
(doc) => doc.contact?._ref === "2286ae51-465b-4866-928a-d0790b26b090"
)
.map((doc) => ({
id: doc._id,
patch: {
set: {
contact: {
_ref: "editor.pv5AzOXXs",
_type: "reference",
},
},
ifRevisionID: doc._rev,
},
}));
docs.map((doc) => ({
id: doc._id,
patch: {
unset: ["under_arbeid"],
ifRevisionID: doc._rev,
},
}));

const createTransaction = (patches) =>
patches.reduce(
Expand All @@ -42,6 +33,8 @@ const commitTransaction = (tx) => tx.commit();

const migrateNextBatch = async () => {
const documents = await fetchDocuments();
console.log(documents.length);
return;
const patches = buildPatches(documents);
if (patches.length === 0) {
console.log("No more documents to migrate!");
Expand Down
148 changes: 0 additions & 148 deletions website/lib/types/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,29 +302,6 @@ Bruk en kort og konsis tittel om mulig. Blir satt som `<H1 />` på toppen av sid
*/
heading?: string;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* url - `Slug`
*/
Expand Down Expand Up @@ -362,11 +339,6 @@ Vil vise under-arbeid status med innhold under
*/
bruk_tab?: riktekst_komponent;

/**
* Kode - `RegistryReference`
*/
kode_tab?: riktekst_komponent;

/**
* Kodepakker - `Array`
*/
Expand Down Expand Up @@ -470,29 +442,6 @@ Bruk en kort og konsis tittel om mulig. Blir satt som `<H1 />` på toppen av sid
*/
heading?: string;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* url - `Slug`
*/
Expand Down Expand Up @@ -530,11 +479,6 @@ Vil vise under-arbeid status med innhold under
*/
bruk_tab?: riktekst_komponent;

/**
* Kode - `RegistryReference`
*/
kode_tab?: riktekst_komponent;

/**
* Kodepakker - `Array`
*/
Expand Down Expand Up @@ -575,29 +519,6 @@ Bruk en kort og konsis tittel om mulig. Blir satt som `<H1 />` på toppen av sid
*/
heading?: string;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* url - `Slug`
*/
Expand Down Expand Up @@ -717,29 +638,6 @@ Legg til relaterte artikler som du tenker er relevant å lese (maks 3)
>
>;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* SEO - `Object`
*/
Expand Down Expand Up @@ -810,29 +708,6 @@ Side, innganger og seo description-tag
*/
content?: riktekst_aksel;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* SEO - `Object`
*/
Expand Down Expand Up @@ -984,29 +859,6 @@ Side, innganger og seo description-tag
*/
content?: riktekst_prinsipp;

/**
* Under arbeid - `Object`
Hvis checked og publisert vil siden vises som under arbeid uten at lenker treffer 404
*/
under_arbeid?: {
/**
* Er under arbeid? - `Boolean`
*/
status?: boolean;

/**
* Forklaring - `Text`
Default: Siden blir for tiden oppdatert!
*/
forklaring?: string;

/**
* Vis fortsatt innhold? - `Boolean`
Vil vise under-arbeid status med innhold under
*/
vis_innhold?: boolean;
};

/**
* SEO - `Object`
*/
Expand Down

0 comments on commit 7c6c101

Please sign in to comment.