-
Notifications
You must be signed in to change notification settings - Fork 2
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
EPIC: lists
Schema + Setup
#356
Comments
Need a way of defining the current active |
really wish @ndrean hopefully this answers your question dwyl/learn-postgresql#94 (comment) 😉 |
@nelsonic You can run Mix.install([
{:kino_db, "~> 0.2.1"},
{:postgrex, "~> 0.16.3"}
]) opts = [
hostname: "localhost",
port: 5432,
username: "postgres",
password: System.fetch_env!("LB_PASSWORD"),
database: "my_db_dev"
]
{:ok, conn} = Kino.start_child({Postgrex, options})
Postgrex.query!(conn, "select * from users;", []) |
Sadly/frustratingly, I've been wrestling with SELECT id
FROM list_items
WHERE person_id=2
GROUP BY list_id, item_id
|
After reading: https://stackoverflow.com/questions/19601948/must-appear-in-the-group-by-clause-or-be-used-in-an-aggregate-function Which gives the example: SELECT DISTINCT ON (cname)
cname, wmname, avg
FROM
makerar
ORDER BY
cname, avg DESC ; I tried: SELECT DISTINCT ON (list_id, item_id)
list_id, item_id, position
FROM list_items But the moment I try to
|
Ok. after going down an annoying rabbit hole in Line 333 in 4a04f86
So I'm just going to write the sorting algo in |
Going to pick this up tomorrow morning when I have a fresh head. |
hey @nelsonic, I saw the new DB update you are modeling. Can you share what you want the Query to return? I can try to help, I have some experience with PostgreSQL. Reading your messages I didn't get the full requirement for the query. |
For context, the Lines 205 to 211 in 4a04f86
Running this query on a working version of the i.e. there are rows that look like duplicates but are in fact representing the multiple distinct timers. What we want, in order to start using I've got this figured out. I just don't get large blocks of time get my work done each day. ⏳ 😞 Getting into this now. 🧑💻 |
This is the SELECT i.id, i.text, i.status, i.person_id,
t.start, t.stop, t.id as timer_id,
li.position as position, li.list_id
FROM items i
FULL JOIN timers AS t ON t.item_id = i.id
JOIN list_items AS li ON li.item_id = i.id
WHERE i.person_id = 2
AND i.status IS NOT NULL
AND li.position != 999999.999
ORDER BY li.position ASC; Busy writing tests, docs and |
After the changes I've made I have 6 failing tests. 💔 |
For complete clarity: the tests that are failing relate to Drag-and-Drop events added in #345 🐉 |
The
We use this Ref: https://www.reddit.com/r/PostgreSQL/comments/mlen8d/can_i_have_array_of_ids_in_where_statement/ |
This is included in #345 ✅ |
Removed |
We’ve gone long enough without creating
lists
.In order to unlock the next level of usefulness, we are going to need
lists
.This was briefly outlined in dwyl/app#271 but I'm opening this issue for implementation in the
MVP
. i.e. this is the basic first implementation. 👌list
requirements:When a person first authenticates with the
App
, automatically create theirlist
called “All”items
are added to thislist
bydefault
.Should the setting to automatically add ALLitems
to the “Everything List” should be configurable?person
can create anew
list (e.g. “Backlog”) and use that the place where allnew
items
are stored.lists
should have the following fields:id
(Int
auto increment PK) of the list used for lookups and routing but not displayed to theperson
text
(String
) - the name of thelist
that will be displayed in theApp
person_id
(Int
) of theperson
that created thelist
status
(Int
) a numeric status applied to the list, see: https://github.com/dwyl/statusesA
list
can have an arbitrary number ofitems
(zero or more) via thelist_items
lookup table.items
can be removed from alist
completely.Rather than adding an extra (
status
) field to thelist_items
table that will benull
99% of the time.We simply use the
position
field and a special value:999999.999
AKA “nine nines”(a nod to the
99.9999999%
High AvailabilityBut in our case we want number to be ridiculously high,
999999.999
rounds to a Million.We cannot use
99.9999999
because we expect many (most?) “Everything”lists
to exceed 100.So to “remove” an
item
from alist
, simply insert a new row intolist_items
withposition=999999.999
Ordering
list_items
is represented by theposition
field, as per: Reorderingitems
#145 (comment)person
performs a re-order operation this inserts anew
row into thelist_items
table thus preserving the full history of thelist
,This will ensure that people can replay changes made to a
list
e.g. if they are working in a remote team and want to see what changes were made by a team member.The text was updated successfully, but these errors were encountered: