Commit Graph

15 Commits (master)

Author SHA1 Message Date
Aravinth Manivannan b7fe7ea5d5
chore: rename gists to gitpad 2022-02-20 19:21:28 +05:30
Aravinth Manivannan c252f06b16
feat: return comment ID after comment creation 2022-02-19 21:40:58 +05:30
Aravinth Manivannan ae08828ac4
chore: add license header 2022-02-19 13:36:21 +05:30
Aravinth Manivannan 96be68c734
fix and chore: apply clippy lints and create_gist returns gist public ID
fixes #1
2022-02-19 13:35:03 +05:30
Aravinth Manivannan 06830bfd2c
feat: DB: visibility filtered gist retrieval
    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

    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

	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

	Return all gists that belong to a user with
	public(GistVisibility::Public) only is returned. Private and
	Unlisted resources are ignored.

	Returns all gists belonging to a user
2022-02-16 17:13:12 +05:30
Aravinth Manivannan 44d920f6ea
feat: implement serialization and deserialiation for Gist, GIstPrivacy and GistComments in db_core 2022-02-15 23:46:05 +05:30
Aravinth Manivannan 303a4ab0ba
feat: helper method Data::new_gist to create new gist and tests
    Data::new_gist creates a bare repository in the supplied
    Data.settings.repository.root directory and saves metadata in the

    See accompanying test for usage
2022-02-14 22:46:17 +05:30
Aravinth Manivannan 79704087f6
fix: change function parameters into references 2022-02-14 22:41:07 +05:30
Aravinth Manivannan 303a430113
fix: rename GistPrivacy to GistVisibility and *privacy to *visibility 2022-02-14 20:38:19 +05:30
Aravinth Manivannan 6b60e2a064
feat: add gists_gists, gists_comments and gists_comments & related methods
The following changes are implemented for both db-sqlx-postgres and

TABLE gists_gists
    Stores gist metadata with unique index on gists_gists.public_id for fast

TABLE gists_comments
    Stores comment metadata

TABLE gists_privacy
    Stores gist privacy: sqlx currently doesn't have support Postgres
    enums(ref:, 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.

    Database indexes are i64 in SQLite while i32 in Postgres
2022-02-14 20:11:26 +05:30
Aravinth Manivannan e96550b6c0
feat: db-sqlx-postgres: reaname admin_users -> gists_users 2022-02-13 16:50:51 +05:30
Aravinth Manivannan 9bf3dad060
feat: db-sqlx-sqlite: reaname admin_users -> gists_users 2022-02-13 16:49:38 +05:30
Aravinth Manivannan f67a0038cf feat : GistDatabase is Clone and add ping to GistDatabase 2022-02-12 23:47:08 +05:30
Aravinth Manivannan aa4d205742 fix: apply lints suggested by clippy 2022-02-12 18:25:03 +05:30
Aravinth Manivannan b28a7d0cfb feat: bootstrap database ops
- db-core: defines base database traits that are required for gists
- db-sqlx-postgres: implements db-core for postgres flavor of the sqlx
- db-sqlx-sqlite: implements db-core for sqlite flavor of the sqlx
2022-02-12 16:35:55 +05:30