SUMMARY
GistDatabase::get_user_gists retrieved all gists that were created by
the user. GistDatabase::get_user_public_gists and
GistDatabase::get_user_public_unlisted_gists produce
visibility-filtered results
DESCRIPTION
Gist visibility levels are ordered in the following order:
---------------------------------
| Public < Unlisted < Private |
---------------------------------
A user with permissions to access a visibility-level will
also have access to the levels lower levels to it. Accessibility
filters use this mechanism to filter gists: a higher
visibility-level request will also return gists with lower
visibility-levels.
GistDatabase::get_user_public_unlisted_gists:
Return all gists that belong to a user with
public(GistVisibility::Public) and
unlisted(GistVisibility::UnliUnlisted) visibility levels. Gists
with private(GistVisibility::Private) visibility levels are
ignored.
GistDatabase::get_user_public_gists:
Return all gists that belong to a user with
public(GistVisibility::Public) only is returned. Private and
Unlisted resources are ignored.
GistDatabase::get_user_gists:
Returns all gists belonging to a user
DESCRIPTION
Data::new_gist creates a bare repository in the supplied
Data.settings.repository.root directory and saves metadata in the
database
See accompanying test for usage
The following changes are implemented for both db-sqlx-postgres and
db-sqlx-sqlite:
TABLE gists_gists
Stores gist metadata with unique index on gists_gists.public_id for fast
lookups
TABLE gists_comments
Stores comment metadata
TABLE gists_privacy
Stores gist privacy: sqlx currently doesn't have support Postgres
enums(ref: https://github.com/launchbadge/sqlx/issues/1171), so storing
possible privacy values as references from this table.
This table shouldn't be mutated during runtime. Possible values are
already recorded in database during migrations. All runtime operations
on this table must only take references.
Each implementation of GistDatabase also includes a method called
privacy_exists, which is called during tests to ensure that
migrations are successful.
VIEW gists_gists_view
Gist lookups combines data from gists_users, gists_gists and
gists_privacy. This SQL view boots performance(I think?). At any rate,
it is much nicer to work with.
QUIRKS
Database indexes are i64 in SQLite while i32 in Postgres
- db-core: defines base database traits that are required for gists
- db-sqlx-postgres: implements db-core for postgres flavor of the sqlx
library
- db-sqlx-sqlite: implements db-core for sqlite flavor of the sqlx
library