fixme icon indicating copy to clipboard operation
fixme copied to clipboard

Add an HFOSS filter to the UI

Open bacharakis opened this issue 7 years ago • 17 comments

Add an HFOSS filter on the UI/filters list screenshot from 2018-09-26 16-36-48

bacharakis avatar Sep 26 '18 21:09 bacharakis

@alexdor Hello Alex, we are trying to add an HFOSS BooleanInput to the admin console, and then, if it is selected, we'd like to have a method execute that will add 'HFOSS' to the tags of the project. Can you help us with the syntax for executing a method if the BooleanInput is set to true?

katiehrenchir avatar Sep 27 '18 18:09 katiehrenchir

Hello @katiehrenchir in order to implement this functionality 2 tasks need to be completed. For the frontend a new boolean field should be added on the src/routes/Admin/components/Projects.tsx file

For the backend, the project model needs to be updated to include a boolean field that indicates whether this project is 'HFOSS' or not (with the default value set to false). In order to achieve that a new column needs to be created at the database and the project model needs to be updated with the new field. Once the model is updated the backend will automatically include the new field on every Get, Post and Put request.

Please let me know if you would like more info about any specific part : )

alexdor avatar Sep 27 '18 18:09 alexdor

Ok! We have added the BooleanInput component to the create and edit sections of src/routes/Admin/components/Projects.tsx <BooleanInput label="HFOSS?" />

and then we also just added this to the backend's Projects.go file HFOSS bool json:"HFOSS" db:"HFOSS"

katiehrenchir avatar Sep 27 '18 18:09 katiehrenchir

Now we would like to have some code that adds 'HFOSS' to the tags of the Project based upon the value of the HFOSS boolean field

katiehrenchir avatar Sep 27 '18 18:09 katiehrenchir

you also need to add a new database migration. You need to create a migration similar to this one migrations/20180830162007_AddTagsToRepos.up.fizz but with the column that you want. You can generate a migration file by running this command buffalo db generate fizz add_hfoss_column_to_projects

alexdor avatar Sep 27 '18 18:09 alexdor

We don't want to create a new column for HFOSS in the database, we just want to add or remove the HFOSS tag from the existing Tags based on the BooleanInput value... can this be accomplished with an "action" instead of a database change?

katiehrenchir avatar Sep 27 '18 18:09 katiehrenchir

Unfortunately, this can't be done by a simple action. The reason is that tags are parsed automatically by GitHub, if you add a tag (with the current setup) it will be overwritten when the project is fetched from GitHub. Another approach (instead of creating a boolean field in the database) is to create a new column of type array (named AdminTags, or something similar) that would store all the extra tags that an admin wants to add to this project.

alexdor avatar Sep 27 '18 18:09 alexdor

How often is the project "fetched"? Is it every time the page is loaded, or only when the project object is created/edited?

katiehrenchir avatar Sep 27 '18 19:09 katiehrenchir

Each project is “fetched” approximately once every 30’ from the worker On Thu, 27 Sep 2018 at 21.01, Katie Hrenchir [email protected] wrote:

How often is the project "fetched"? Is it every time the page is loaded, or only when the project object is created/edited?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ossn/fixme/issues/13#issuecomment-425206440, or mute the thread https://github.com/notifications/unsubscribe-auth/AICth6sOewP9snxqdIwIX6xWVIdp4JYZks5ufSBpgaJpZM4W7iWB .

alexdor avatar Sep 27 '18 19:09 alexdor

Alex, this is our migration add_column("projects", "HFOSS", "boolean", {"null": true})

and we added this line to the admin Projects file <BooleanField source="HFOSS" label="HFOSS?" />

Christos said that the environment should automatically do the migration for us? However, the admin console's projects list now says "No results found" so something about this is wrong, I suspect the migration. I think this added HFOSS to the Projects table, right?

katiehrenchir avatar Sep 27 '18 19:09 katiehrenchir

I would suggest to change the migration to

add_column("projects", "HFOSS", "boolean", {"default": false})

In order to run the migration, stop and start the running docket instance

On Thu, 27 Sep 2018 at 21.10, Katie Hrenchir [email protected] wrote:

Alex, this is our migration add_column("projects", "HFOSS", "boolean", {"null": true})

and we added this line to the admin Projects file <BooleanField source="HFOSS" label="HFOSS?" />

Christos said that the environment should automatically do the migration for us? However, the admin console's projects list now says "No results found" so something about this is wrong, I suspect the migration. I think this added HFOSS to the Projects table, right?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ossn/fixme/issues/13#issuecomment-425209438, or mute the thread https://github.com/notifications/unsubscribe-auth/AICth_44u-UeEI6FZ2dOObSBXGhrs5Kmks5ufSK1gaJpZM4W7iWB .

alexdor avatar Sep 27 '18 19:09 alexdor

Alex, here is the output: https://pastebin.com/1eXwtCyK

katiehrenchir avatar Sep 27 '18 19:09 katiehrenchir

@katiehrenchir could you upload the source code somewhere as well so I can try to see why is the migration not running? (You could push it to your fork of the repo)

alexdor avatar Sep 27 '18 19:09 alexdor

Alex, I have pushed the changes to my fork of the backend.

katiehrenchir avatar Sep 27 '18 19:09 katiehrenchir

I've left a comment with a possible issue, when you have a look and let me know if it worked : )

alexdor avatar Sep 27 '18 20:09 alexdor

@alexdor is this being worked on now?

siddhant1 avatar Mar 04 '19 13:03 siddhant1

@siddhant1 no I've left my comments here https://github.com/katiehrenchir/fixme_backend/commit/4fa6636bd25a46b9cae13d1d9ca24ace1041a05b

alexdor avatar Mar 04 '19 13:03 alexdor