SeedCompany / cord-api-v3

Bible translation project management API
MIT License
18 stars 4 forks source link

[EdgeDB] Add Pins Seeding #3212

Closed bryanjnelson closed 4 months ago

bryanjnelson commented 4 months ago

Monday task

Description

Add seeding for pinnable types; some test users now have populated pins for projects, languages, and/or partners

Ready for review checklist

Use [N/A] if the item is not applicable to this PR or remove the item

  • [X] Change the task url above to the actual Monday task
  • [N/A] Add/update tests if needed
  • [X] Add reviewers to this PR
CarsonF commented 4 months ago

Yeah I'd have pins in its own file.

Update could simply be:

update User
filter .realFirstName = "Bilbo"
set {
  pins += (
    select Mixin::Pinnable
    filter [is Mixin::Named].name = {"Sindarin", "Quenya", "South Downs"}
  )
};
bryanjnelson commented 4 months ago

@CarsonF - Do you think there is enough benefit in keeping the json separated like this into languages, partners, and projects even though they could technically just be one big list of pinnables?

with
  usersJson := to_json('[
    {
      "user": "Bilbo",
      "pinnables": {
        "languages": ["Sindarin", "Quenya"],
        "partners": ["Dwarvish/Elvish Alliance", "Fellowship of Halfing Languages"],
        "projects": ["Emyn Muil", "Arnor Lake", "South Downs"]
      },
    }
  ]'),

Basically does seeing that structure at the top introduce enough benefit to see what type of pins we are adding, over flattening that structure into a list of names and having less code overall?

CarsonF commented 4 months ago

I don't see much benefit...I would just flatten

bryanjnelson commented 4 months ago

@CarsonF - This seems to modifying the data correctly, but the printed output is odd to me:

[
  {
    "Modified Users": [
      "Bilbo Baggins",
      "Bilbo Baggins",
      "Bilbo Baggins",
      "Peregrin Took",
      "Peregrin Took",
      "Peregrin Took",
      "Aragorn Son of Arathorn",
      "Aragorn Son of Arathorn",
      "Aragorn Son of Arathorn"
    ]
  }
]

I would expect this:

[
  {
    "Modified Users": [
      "Bilbo Baggins",
      "Peregrin Took",
      "Aragorn Son of Arathorn"
    ]
  }
]

Probably something simple?

CarsonF commented 4 months ago

Probably something simple?

Need a distinct somewhere. Either

users := distinct (...)

or

modified := distinct (...)

or

modified := (select distinct users ...)

all work.