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

Implement infrastructure for storing Idea Hub idea information with WordPress posts #3157

Closed
felixarntz opened this issue Apr 15, 2021 · 7 comments
Labels
Module: Idea Hub Google Idea Hub module related issues P0 High priority QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Milestone

Comments

@felixarntz
Copy link
Member

felixarntz commented Apr 15, 2021

Since the Idea Hub module will allow creating WordPress posts based on Idea Hub ideas, it should be possible to store an idea's full information within a post. See more information on the overall approach.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • A new Google\Site_Kit\Modules\Idea_Hub\Post_Idea_Name class should be implemented which extends Google\Site_Kit\Core\Storage\Post_Meta_Setting.
    • Its meta key should be googlesitekitpersistent_idea_name.
    • Its type should be a string (it's expecting a slug).
  • A new Google\Site_Kit\Modules\Idea_Hub\Post_Idea_Text class should be implemented which extends Google\Site_Kit\Core\Storage\Post_Meta_Setting.
    • Its meta key should be googlesitekitpersistent_idea_text.
    • Its type should be a string (it's expecting a human-readable label).
  • A new Google\Site_Kit\Modules\Idea_Hub\Post_Idea_Topics class should be implemented which extends Google\Site_Kit\Core\Storage\Post_Meta_Setting.
    • Its meta key should be googlesitekitpersistent_idea_topics.
    • Its type should be an array (it's expecting a list of objects / associative arrays, each with mid and display_name fields).
    • Its sanitize callback should ensure every entry within the array is an associative array with mid and display_name string fields.
  • The Idea_Hub class should register the new Post_Meta_Settings implemented.
  • The Idea_Hub class should receive two new protected methods:

Implementation Brief

Following #3154,

Create a new file includes/Modules/Idea_Hub/Post_Idea_Name.php

class Post_Idea_Name extends Post_Meta_Setting {
	const META_KEY = 'googlesitekitpersistent_idea_name';
}

Create a new file includes/Modules/Idea_Hub/Post_Idea_Text.php

class Post_Idea_Text extends Post_Meta_Setting {
	const META_KEY = 'googlesitekitpersistent_idea_text';
} 

Create a new file includes/Modules/Idea_Hub/Post_Idea_Topics.php

class Post_Idea_Topics extends Post_Meta_Setting {
	const META_KEY = 'googlesitekitpersistent_idea_topics';

	protected function get_type() {
		return 'array';
	}

	protected function get_sanitize_callback() {
		return function ($option) {
			// @TODO: Sanitize callback should ensure every entry within the array
			// is an associative array with mid and display_name string fields.
			return $option;
		};
    }
}

Update the register() function in includes/Modules/Idea_Hub.php to register each of the new Post_Meta_Settings above.

Add two new functions to includes/Modules/Idea_Hub.php, set_post_idea() and get_post_idea() per the AC.

Test Coverage

Update tests/phpunit/integration/Modules/Idea_HubTest.php to add test_set_post_idea() and test_get_post_idea()

Visual Regression Changes

  • N/A

QA Brief

  • Check the Idea_Hub class to make sure it registers settings defined in the AC.
  • Also verify that the Idea_Hub has two new methods set_post_idea and get_post_idea and they work as required in the AC.

Changelog entry

  • N/A
@felixarntz felixarntz added P0 High priority Type: Enhancement Improvement of an existing feature QA: Eng Requires specialized QA by an engineer labels Apr 15, 2021
@felixarntz felixarntz assigned felixarntz and unassigned felixarntz Apr 15, 2021
@felixarntz felixarntz added the Module: Idea Hub Google Idea Hub module related issues label Apr 15, 2021
@fhollis fhollis added this to the Sprint 48 milestone Apr 21, 2021
@eugene-manuilov eugene-manuilov self-assigned this Apr 26, 2021
@eugene-manuilov
Copy link
Collaborator

@ivankruchkoff the Post_Meta_Setting::get_type method already returns string by default, so there is no need in overriding this method in Post_Idea_Name and Post_Idea_Text classes. Also, please, try to avoid using code snippets when possible. Better use narrative statements that explain what needs to be done in specific places.

Update tests/phpunit/integration/Modules/Idea_HubTest.php

Could you please elaborate a little bit more here? What exactly needs to be updated there? Do we need to add new tests or update existing ones?

@ivankruchkoff
Copy link
Contributor

@ivankruchkoff the Post_Meta_Setting::get_type method already returns string by default, so there is no need in overriding this method in Post_Idea_Name and Post_Idea_Text classes. Also, please, try to avoid using code snippets when possible. Better use narrative statements that explain what needs to be done in specific places.

Updated

Update tests/phpunit/integration/Modules/Idea_HubTest.php

Could you please elaborate a little bit more here? What exactly needs to be updated there? Do we need to add new tests or update existing ones?

Updated

@eugene-manuilov
Copy link
Collaborator

IB ✔️

@tofumatt tofumatt removed their assignment May 13, 2021
@asvinb asvinb self-assigned this May 14, 2021
@asvinb
Copy link
Collaborator

asvinb commented May 14, 2021

@eugene-manuilov The get_post_idea method should return null if any of the 3 pieces of data is not stored. I don't see that part implemented. Can you check please?

QA: Waiting for engineer to confirm

@asvinb asvinb assigned eugene-manuilov and unassigned asvinb May 14, 2021
@eugene-manuilov
Copy link
Collaborator

@asvinb yes, it hasn't been added. I'll create a follow up PR.

@eugene-manuilov eugene-manuilov removed their assignment May 14, 2021
@tofumatt tofumatt self-assigned this May 14, 2021
@tofumatt
Copy link
Collaborator

Thanks @asvinb, sorry I missed that bit in the PR! 😓

@tofumatt tofumatt assigned asvinb and unassigned tofumatt May 14, 2021
@asvinb
Copy link
Collaborator

asvinb commented May 17, 2021

No worries @tofumatt .

QA ✅

@asvinb asvinb removed their assignment May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Idea Hub Google Idea Hub module related issues P0 High priority QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants