meilisearch-go icon indicating copy to clipboard operation
meilisearch-go copied to clipboard

Add `updatedAt` and `createdAt` to `Index`

Open curquiza opened this issue 3 years ago • 3 comments

When manipulating indexes (get/create/update), the MeiliSearch server returns the following information related to the index:

  • uid: the uid of the index
  • primaryKey: the primary key of the index
  • updateAt: when the index has been updated
  • createdAt: when the index has been created

This SDK, when manipulating indexes (get/create/update) returns an instance of Index which already contains the primaryKey and uid members.

It means we can currently get the primaryKey and the uid, but not updatedAt and createdAt.

TODO:

  • [x] Add updatedAt and createdAt member in the Index class/struct (depending on the language).
  • [ ] Update the variable in the code where primaryKey is already updated. Ex: when getting the index with getIndex()
  • [ ] Add tests

⚠️ This issue is generated, it means primaryKey, updatedAt, and createdAt might be named differently in this package (ex: primary_key instead). Keep the already existing way of naming in this package to stay idiomatic with the language and the repository. Also, if you are a maintainer, feel free to add any clarification and instruction about this issue related to the specific languages of the repo.

Related to https://github.com/meilisearch/integration-guides/issues/121

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.

curquiza avatar Oct 10 '21 18:10 curquiza

Can I please work on this?

kashifsoofi avatar Oct 11 '21 09:10 kashifsoofi

Spoke too fast, looks like Index already have those properties

kashifsoofi avatar Oct 11 '21 09:10 kashifsoofi

Hi @kashifsoofi, You're right the two fields already exist but It seems they aren't well updated and the tests are missing too.

alallema avatar Oct 11 '21 12:10 alallema

@curquiza I'm looking to implement the 2nd todo but I don't understand what it means

Azanul avatar Jan 24 '23 08:01 Azanul

In this function

func (i Index) FetchInfo() (resp *Index, err error) {
	resp = newIndex(i.client, i.UID)
	req := internalRequest{
		endpoint:            "/indexes/" + i.UID,
		method:              http.MethodGet,
		withRequest:         nil,
		withResponse:        resp,
		acceptedStatusCodes: []int{http.StatusOK},
		functionName:        "FetchInfo",
	}
	if err := i.client.executeRequest(req); err != nil {
		return nil, err
	}
	i.PrimaryKey = resp.PrimaryKey //nolint:golint,staticcheck
	return resp, nil
}

index is passed as value instead of pointer, what's the point of i.PrimaryKey = resp.PrimaryKey ?

Azanul avatar Jan 24 '23 10:01 Azanul

Hi @Azanul

@curquiza I'm looking to implement the 2nd todo but I don't understand what it means

The second todo explains that when you use the GetIndex() method you pass through the FetchInfo() method which uses an instance of the Index in question but the data in the index must be updated at the same time

index is passed as value instead of pointer, what's the point of i.PrimaryKey = resp.PrimaryKey ?

This is what we have fixed by:

func (i *Index) FetchInfo() (resp *Index, err error) {

And also update the updateAt and createdAt

alallema avatar Mar 01 '23 13:03 alallema

Leaving this for someone else, don't want to hog all good first issues for myself.

Azanul avatar Jun 06 '23 00:06 Azanul

Feel free to do whatever you like.

alallema avatar Jun 06 '23 05:06 alallema

@tanbirali @ayesha-firdaus @rafiya2003

Azanul avatar Jun 06 '23 05:06 Azanul

I would like to do this work

rafiya2003 avatar Jun 06 '23 05:06 rafiya2003

While @rafiya2003 completes task 2, @tanbirali @ayesha-firdaus you guys can look into adding tests if interested.

Azanul avatar Jun 06 '23 15:06 Azanul

While @rafiya2003 completes task 2, @tanbirali @ayesha-firdaus you guys can look into adding tests if interested.

You can indeed add the missing tests to another PR, but as for the rest, each piece of code added must be accompanied by the corresponding tests.

alallema avatar Jun 07 '23 08:06 alallema