Add /api/v1/offline/prefetch endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
55a22a4f4c
commit
f273fc5d9b
@ -6,6 +6,42 @@ class OfflineController extends Controller {
|
|||||||
return [...super.services, 'models', 'controllers', 'app']
|
return [...super.services, 'models', 'controllers', 'app']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async do_prefetch(req, res, next) {
|
||||||
|
const PageModel = this.models.get('api:Page')
|
||||||
|
const PageNode = this.models.get('api:Node')
|
||||||
|
const Codium = this.models.get('api:Codium')
|
||||||
|
const Database = this.models.get('api:db:Database')
|
||||||
|
const ColumnDef = this.models.get('api:db:ColumnDef')
|
||||||
|
const DBEntry = this.models.get('api:db:DBEntry')
|
||||||
|
const FileGroup = this.models.get('api:FileGroup')
|
||||||
|
|
||||||
|
const pages = (await PageModel.visible_by_user(req.user)).filter(x => x.Active)
|
||||||
|
const page_uuids = pages.map(x => x.UUID)
|
||||||
|
|
||||||
|
const pageNodes = await PageNode.find({ PageId: { $in: page_uuids }})
|
||||||
|
|
||||||
|
const codiums = await Codium.find({ PageId: { $in: page_uuids }, Active: true })
|
||||||
|
|
||||||
|
const databases = await Database.find({ PageId: { $in: page_uuids }, Active: true })
|
||||||
|
const database_uuids = databases.map(x => x.UUID)
|
||||||
|
|
||||||
|
const databaseColumns = await ColumnDef.find({ DatabaseId: { $in: database_uuids }})
|
||||||
|
|
||||||
|
const databaseEntries = await DBEntry.find({ DatabaseId: { $in: database_uuids }})
|
||||||
|
|
||||||
|
const fileGroups = await FileGroup.find({ PageId: { $in: page_uuids }})
|
||||||
|
|
||||||
|
return res.api({
|
||||||
|
pages,
|
||||||
|
pageNodes,
|
||||||
|
codiums,
|
||||||
|
databases,
|
||||||
|
databaseColumns,
|
||||||
|
databaseEntries,
|
||||||
|
fileGroups,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async do_sync(req, res, next) {
|
async do_sync(req, res, next) {
|
||||||
// TODO account for modify date to not overwrite more recent data!!
|
// TODO account for modify date to not overwrite more recent data!!
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ const index = {
|
|||||||
'/data/export/html': ['controller::Export.html_export'],
|
'/data/export/html': ['controller::Export.html_export'],
|
||||||
|
|
||||||
'/search': ['controller::api:v1:Misc.get_search'],
|
'/search': ['controller::api:v1:Misc.get_search'],
|
||||||
|
|
||||||
|
'/offline/prefetch': ['controller::api:v1:Offline.do_prefetch'],
|
||||||
},
|
},
|
||||||
|
|
||||||
post: {
|
post: {
|
||||||
|
Loading…
Reference in New Issue
Block a user