Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plastic Strategy #1611

Open
lucassousaf opened this issue Sep 25, 2023 · 0 comments
Open

Plastic Strategy #1611

lucassousaf opened this issue Sep 25, 2023 · 0 comments
Assignees
Labels
Backend Backend related issue

Comments

@lucassousaf
Copy link
Contributor

We need to manage the following information:

  • Plastic strategies.
  • Plastic strategies' steps.
  • Plastic strategy's groups.
  • Plastic strategy resources' bookmarks.
@lucassousaf lucassousaf added the Backend Backend related issue label Sep 25, 2023
@lucassousaf lucassousaf self-assigned this Sep 25, 2023
lucassousaf added a commit that referenced this issue Oct 4, 2023
lucassousaf added a commit that referenced this issue Oct 4, 2023
[Re #1611]

* After discussing options internally with Martin, it was decided to
use JSONB to store the steps of the plastic strategy. It's going to be
faster for the FE iterations.
lucassousaf added a commit that referenced this issue Oct 4, 2023
lucassousaf added a commit that referenced this issue Oct 4, 2023
lucassousaf added a commit that referenced this issue Oct 4, 2023
[Re #1611]

* Assignments are unique per plastic strategy, user and group
type.
* The roles stored in this table is just an annotation for FE
purposes, the real permissions assignment will be handled by RBAC.
lucassousaf added a commit that referenced this issue Oct 5, 2023
[Re #1611]

* Each plastic strategy has a team and inside there are "teams" which
acts as internal/sub teams of the broader PS team. So, we just need to
add or remove team members from the broader team.
* Each team member can be part of N internal/sub "teams".
lucassousaf added a commit that referenced this issue Oct 5, 2023
[Re #1611]

* This is a rewrite of the previous implementation to adjust to the
model changes. It also includes new functions to delete and get team members.
lucassousaf added a commit that referenced this issue Oct 5, 2023
[Re #1611]

* Incl. add-ps-team-member and update-ps-team-member.
* The "role" field in the "plastic_strategy_team_member" table is an
annotation for FE display purposes. The real role and permissions are
handled using the RBAC system.
* Each role annotation maps to other 3 roles in rbac:
 - viewer -> plastic-strategy-viewer
 - editor -> plastic-strategy-editor
 - admin -> plastic-strategy-admin
lucassousaf added a commit that referenced this issue Oct 6, 2023
[Re #1611]

* Given a list of GPML countries IDs, creates a plastic strategy
record for each.
lucassousaf added a commit that referenced this issue Oct 6, 2023
lucassousaf added a commit that referenced this issue Oct 6, 2023
[Re #1611]

* We'll need the RBAC contexts as we'll use permissions to control
access of users to plastic strategy's API resources.
lucassousaf added a commit that referenced this issue Oct 6, 2023
[Re #1611]

* The teams properties are used internally as keywords so before
inserting into the db and before returning to callers we should
transform all the values of teams key into keywords.
lucassousaf added a commit that referenced this issue Oct 6, 2023
[Re #1611]

* The "ps-team-member" role can be "nil" so we need to consider that
option as well.
lucassousaf added a commit that referenced this issue Oct 6, 2023
[Re #1611]

* Support for adding, editing and getting team members.
lucassousaf added a commit that referenced this issue Oct 6, 2023
lucassousaf added a commit that referenced this issue Oct 9, 2023
lucassousaf added a commit that referenced this issue Oct 9, 2023
[Re #1611]

* Also added a new permission to add a team member.
* Renamed the permissions to be consistent with naming policy
used (update instead of edit).
* Removed the "plastic-strategy/add-team-member" permission from the
"plastic-strategy-editor" role as it was wrong. Although they are
editors, they can't edit the team. It's a restricted feature for
"plastic-strategy-admin"s only.
lucassousaf added a commit that referenced this issue Oct 9, 2023
lucassousaf added a commit that referenced this issue Oct 9, 2023
[Re #1611]

* The invitiation type is to distinguish which type of invitation
it's. As of now we have one type of invitation in production which is
"expert" and with PS we need another type of invitation. As experts
have extra logic when the user actually accepts the invitation, the
"INVITED" status is not enough. So this "type" column will give us the
necessary information to distinguish both cases and more in the future.
lucassousaf added a commit that referenced this issue Oct 9, 2023
[Re #1611]

* The invitiation type is to distinguish which type of invitation
it's. As of now we have one type of invitation in production which is
"expert" and with PS we need another type of invitation. As experts
have extra logic when the user actually accepts the invitation, the
"INVITED" status is not enough. So this "type" column will give us the
necessary information to distinguish both cases and more in the future.
lucassousaf added a commit that referenced this issue Oct 10, 2023
lucassousaf added a commit that referenced this issue Oct 10, 2023
[Re #1611]

* Also refactor it to follow new conventions on the persistence layer
side, handling errors at that level.
lucassousaf added a commit that referenced this issue Oct 10, 2023
[Re #1611]

* This was missing in previous commits.
lucassousaf added a commit that referenced this issue Oct 10, 2023
[Re #1611]

* Users invited to plastic strategy will also have they required RBAC
roles added and RocketChat account created as well.
* Also fixed the rollbacks for update-stakeholder as they were in the
wrong txn-fns.
joseAyudarte91 added a commit that referenced this issue Oct 23, 2023
[Re #1611]

Added new programmatic API endpoint for creating a Badge. As always,
this endpoint is restricted for internal usage.

We are not using JDBC transactions in the process since we need to
perform side-effectful operations that cannot be just undone by
aborting JDBC transactions, so we are explictly doing rollbacks when
some steps cannot be performed and some others have been already
committed.
joseAyudarte91 added a commit that referenced this issue Oct 23, 2023
[Re #1611]

The new endpoint expects a `name` path parameter to find the target
Badge by its unique name, as this is the most useful way to use this
endpoint. As part of the data fetch the endpoint provides the content
file's URL, retrieved from GCS. The `content-file-id` parameter is not
used after getting the file url, so we remove it from the result.
joseAyudarte91 added a commit that referenced this issue Oct 23, 2023
[Re #1611]

This new endpoint behaves in a similar way as the PS Bookmark-related
endpoint, in the sense that it can be used for both assigning or
unassigning a badge from a given entity type, providing a flag to know
the action and other details to identify the resource type, id and the
badge id as well.

In this case we are handling the entity type in an easier and safer way
than it is done with PS Bookmarking, as we are avoiding relying on `_`
separator to infer the entity type. Hence, this bug will need to be
fixed in PS Bookmark handling, but that is a separated issue.

As a side note, we are sharing a single param for both GET and POST
Assign Badge endpoints, in order to avoid route conflicts, so the path
param can be an integer id or a name string in each case, what could be
confusing, as one can imagine that you can provide name or id for both
endpoints, but it doesn't work like that (as explained in the Swagger
params.
lucassousaf added a commit that referenced this issue Oct 24, 2023
[Re #1611]

* In cases where the entity type is "case_study" the
"ps-bookmark-entity-col" splitting will produce a wrong
"entity-name". So instead of doing all of this work of splitting the
"ps-bookmark-entity-col" we can just pass the "entity-type" already
available in our service layer.
lucassousaf added a commit that referenced this issue Oct 24, 2023
…1671)

* Fix PS bookmark entity-type parsing for constraint violation check

[Re #1611]

* In cases where the entity type is "case_study" the
"ps-bookmark-entity-col" splitting will produce a wrong
"entity-name". So instead of doing all of this work of splitting the
"ps-bookmark-entity-col" we can just pass the "entity-type" already
available in our service layer.
lucassousaf added a commit that referenced this issue Oct 24, 2023
joseAyudarte91 added a commit that referenced this issue Oct 24, 2023
[Re #1611]

Now we load assigned badges metadata to each resource fetched with this
endpoint. However, we are just providing relationship-related data and
Badge's related extra data, such the File content URL, needs to be
fetched using the individual `/api/badge` GET endpoint.

For now we do not offer filtering or sorting capabilities regarding
badges. That can also comes in the future.
joseAyudarte91 added a commit that referenced this issue Oct 24, 2023
[Re #1611]

We load badge id as part of the relationship data of badge-resource
assignments, so it make sense we can use the badge id to obtain all of
its information, instead of just allowing to get it by its unique
name.

Added more clarifications about the shared context `id-or-name`
parameter, as for assignments we only expect the badge id to be
provided, as that is easier than using the name, for that case.
joseAyudarte91 added a commit that referenced this issue Oct 24, 2023
[Re #1611]

Renamed the new DB migration after the merge, as we were using an
already existing number.
lucassousaf added a commit that referenced this issue Oct 24, 2023
[Re #1611]

* PS bookmark would be duplicated in some occurrences. This might be due to the query complexity of `LEFT JOIN`s generating multiple rows for a single entity even after grouping. For now this is a quick fix but we should take quality time to refactor this query to make it right.
joseAyudarte91 added a commit that referenced this issue Oct 25, 2023
[Re #1611]

The initial specs were wrong due to some misunderstanding, so we need to
get rid of the `content-file-id` property from Badge entity and update
the code accordingly.

On the other hand, we also need to support additional badge types for
the platform.
lucassousaf added a commit that referenced this issue Oct 25, 2023
joseAyudarte91 added a commit that referenced this issue Oct 25, 2023
joseAyudarte91 added a commit that referenced this issue Oct 25, 2023
[Re #1611]

We need to support assinging and unassigning badge by its unique name
since it is more convinient for FE to avoid relying on extra GET call
for getting the badge ids.

We have decided to support both name and id properties here because it's
easier and we can share same specs for the GET and POST Assign Badge
endpoints, regarding path params.
joseAyudarte91 added a commit that referenced this issue Oct 26, 2023
[Re #1611]

We need to include the same information we are adding in other APIs such
as Submission one, in order to conditionally load Badges
assignation-related metadata for the listed organisations.
lucassousaf added a commit that referenced this issue Oct 31, 2023
[Re #1611]

* Otherwise it wouldn't match the name real constraint name on the
database and thus not throw the expected error.
lucassousaf added a commit that referenced this issue Oct 31, 2023
[Re #1611]

* Every user added to a plastic strategy needs to have a chat account
enabled in order to add them to the PS channel. Therefore, I added an
extra step to create the user account in RocketChat if it doesn't have
one already. Since creating the "Forum" (i.e. RocketChat) account is
completely transparent for the user using the platform, this is also
something that only concerns the BE.
lucassousaf added a commit that referenced this issue Oct 31, 2023
[Re #1611]

* Also return a 409 status code when this case happens.
lucassousaf added a commit that referenced this issue Oct 31, 2023
[Re #1611]

* Every user added to a plastic strategy needs to have a chat account enabled in order to add them to the PS channel. Therefore, I added an extra step to create a user account in RocketChat if it doesn't have one already. Since creating the "Forum" (i.e. RocketChat) account is completely transparent for the user using the platform, this is also something that only concerns the BE.
* Improved the error handling on the `add-ps-team-member` handler and service layer to return conflict if the team member already exists.
joseAyudarte91 added a commit that referenced this issue Nov 6, 2023
endpoint

[Re #1611]

We need to filter the strengths count according to the provided PS iso
code from the params, so only those bookmarked initiatives for the
given PS are taking into account when the PS iso code is provided. In
this case, we do not count again same bookmarks for different sections,
as it is only relevant the PS used to bookmark those initiatives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Backend related issue
Projects
None yet
Development

No branches or pull requests

1 participant