diff --git a/backend/lint.sh b/backend/lint.sh new file mode 100644 index 0000000..1c75990 --- /dev/null +++ b/backend/lint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "no lint" \ No newline at end of file diff --git a/backend/src/api/governance-action-type/content-types/governance-action-type/schema.json b/backend/src/api/governance-action-type/content-types/governance-action-type/schema.json index 3e99120..9e12d9d 100644 --- a/backend/src/api/governance-action-type/content-types/governance-action-type/schema.json +++ b/backend/src/api/governance-action-type/content-types/governance-action-type/schema.json @@ -4,10 +4,11 @@ "info": { "singularName": "governance-action-type", "pluralName": "governance-action-types", - "displayName": "Governance action type" + "displayName": "Governance action type", + "description": "" }, "options": { - "draftAndPublish": false + "draftAndPublish": true }, "pluginOptions": {}, "attributes": { diff --git a/backend/src/api/governance-action-type/controllers/governance-action-type.js b/backend/src/api/governance-action-type/controllers/governance-action-type.js index fc2ad1e..a1a5ee0 100644 --- a/backend/src/api/governance-action-type/controllers/governance-action-type.js +++ b/backend/src/api/governance-action-type/controllers/governance-action-type.js @@ -1,9 +1,62 @@ -'use strict'; +// @ts-nocheck +"use strict"; /** * governance-action-type controller */ -const { createCoreController } = require('@strapi/strapi').factories; +const axios = require("axios"); +const { createCoreController } = require("@strapi/strapi").factories; -module.exports = createCoreController('api::governance-action-type.governance-action-type'); +module.exports = createCoreController( + "api::governance-action-type.governance-action-type", + ({ strapi }) => ({ + async find(ctx) { + const sanitizedQueryParams = await this.sanitizeQuery(ctx); + + try { + const { data } = await axios.get( + `${process.env.GOVTOOL_API_BASE_URL}/epoch/params` + ); + + if (data) { + if (!sanitizedQueryParams.filters) { + sanitizedQueryParams.filters = {}; + } + + if (+data?.protocol_major < 9) { + sanitizedQueryParams.filters = { + ...sanitizedQueryParams.filters, + $and: [ + { + gov_action_type_name: { + $ne: "Treasury", + }, + }, + { + gov_action_type_name: { + $ne: "Info", + }, + }, + ], + }; + } + if (+data?.protocol_major === 9) { + sanitizedQueryParams.filters = { + ...sanitizedQueryParams.filters, + gov_action_type_name: { + $ne: "Treasury", + }, + }; + } + } + } catch (error) {} + + const { results, pagination } = await strapi + .service("api::governance-action-type.governance-action-type") + .find(sanitizedQueryParams); + + return this.transformResponse(results, { pagination }); + }, + }) +); diff --git a/backend/types/generated/contentTypes.d.ts b/backend/types/generated/contentTypes.d.ts index 92fe438..c785bc4 100644 --- a/backend/types/generated/contentTypes.d.ts +++ b/backend/types/generated/contentTypes.d.ts @@ -873,9 +873,10 @@ export interface ApiGovernanceActionTypeGovernanceActionType singularName: 'governance-action-type'; pluralName: 'governance-action-types'; displayName: 'Governance action type'; + description: ''; }; options: { - draftAndPublish: false; + draftAndPublish: true; }; attributes: { gov_action_type_name: Attribute.String & @@ -885,6 +886,7 @@ export interface ApiGovernanceActionTypeGovernanceActionType }>; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; createdBy: Attribute.Relation< 'api::governance-action-type.governance-action-type', 'oneToOne', diff --git a/backend/unit-test.sh b/backend/unit-test.sh new file mode 100644 index 0000000..9ba7520 --- /dev/null +++ b/backend/unit-test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "unit tests" \ No newline at end of file