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

feat: analytics module gets and updates PlanX DB #4071

Merged
merged 7 commits into from
Dec 18, 2024
Merged

Conversation

zz-hh-aa
Copy link
Collaborator

What's new in this PR

  • Migration to add metabase_id column to teams in PlanX DB
  • Update Hasura permissions for api to be able to read and update relevant values
  • A getTeamIdAndMetabaseId function
  • An updateMetabaseId function
  • Tests for the above

Why

  • Daf suggested that a better pattern than querying Metabase every time we want to check if a collection exists would be to store a metabase_id in the PlanX DB and check that instead
  • This is the PlanX DB portion of big PR wip: feat: collection service & controller #3971

@zz-hh-aa zz-hh-aa requested a review from jamdelion December 11, 2024 17:17
Copy link

github-actions bot commented Dec 11, 2024

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Updated Tables (1)

  • public.teams permissions:

    insert select update delete
    api /
    2 added column permissions
    insert select update
    api ➕ metabase_id ➕ metabase_id

Copy link

github-actions bot commented Dec 11, 2024

Removed vultr server and associated DNS entries

Copy link
Contributor

@jamdelion jamdelion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just hopping on as I realised I'd forgotten to review these for you! This is looking pretty good to me, though we are getting an integration test failure:

 FAIL  teams.test.js > teams > api > cannot create, update, or delete teams
Error: 'teams' unexpectedly found in mutation(s) [update_teams,update_teams_by_pk,update_teams_many]
 ❯ teams.test.js:102:17
    100| 
    101|     test("cannot create, update, or delete teams", () => {
    102|       expect(i).toHaveNoMutationsFor("teams");
       |                 ^
    103|     });
    104|   });

This is because we have added a mutation (update metabase ID in the teams table), where previously the api role did not have any mutations.

I guess we should update the test to instead expect the mutation (similar to the can query teams test in the same file)

const response = await $api.client.request<GetMetabaseId>(
gql`
query GetTeamAndMetabaseId($name: String!) {
teams(where: { name: { _ilike: $name } }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ilike could match both "North Somerset" and "South Somerset" - it would be better to match using _eq on team slugs if possible which are guaranteed to be unique.

Copy link
Collaborator Author

@zz-hh-aa zz-hh-aa Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Updated in ba015dc.

after teams table migration
and match in planx db on equality instead
@zz-hh-aa zz-hh-aa merged commit bdc3467 into main Dec 18, 2024
12 checks passed
@zz-hh-aa zz-hh-aa deleted the oz/analytics-planx-db branch December 18, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants