MOBILE-3523 data: Fix database prefetch
parent
6dac0af34d
commit
042ee24d0a
|
@ -260,6 +260,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
sort: Number(this.search.sortBy),
|
sort: Number(this.search.sortBy),
|
||||||
order: this.search.sortDirection,
|
order: this.search.sortDirection,
|
||||||
page: this.search.page,
|
page: this.search.page,
|
||||||
|
cmId: this.module.id,
|
||||||
}).then((entries) => {
|
}).then((entries) => {
|
||||||
const numEntries = entries.entries.length;
|
const numEntries = entries.entries.length;
|
||||||
const numOfflineEntries = entries.offlineEntries.length;
|
const numOfflineEntries = entries.offlineEntries.length;
|
||||||
|
|
|
@ -608,8 +608,11 @@ export class AddonModDataProvider {
|
||||||
*/
|
*/
|
||||||
getDatabaseAccessInformation(dataId: number, options: AddonModDataAccessInfoOptions = {}): Promise<any> {
|
getDatabaseAccessInformation(dataId: number, options: AddonModDataAccessInfoOptions = {}): Promise<any> {
|
||||||
return this.sitesProvider.getSite(options.siteId).then((site) => {
|
return this.sitesProvider.getSite(options.siteId).then((site) => {
|
||||||
|
options.groupId = options.groupId || 0;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
databaseid: dataId,
|
databaseid: dataId,
|
||||||
|
groupid: options.groupId,
|
||||||
};
|
};
|
||||||
const preSets = {
|
const preSets = {
|
||||||
cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId),
|
cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId),
|
||||||
|
@ -618,10 +621,6 @@ export class AddonModDataProvider {
|
||||||
...this.sitesProvider.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...this.sitesProvider.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof options.groupId !== 'undefined') {
|
|
||||||
params['groupid'] = options.groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return site.read('mod_data_get_data_access_information', params, preSets);
|
return site.read('mod_data_get_data_access_information', params, preSets);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -636,7 +635,7 @@ export class AddonModDataProvider {
|
||||||
getEntries(dataId: number, options: AddonModDataGetEntriesOptions = {}): Promise<AddonModDataEntries> {
|
getEntries(dataId: number, options: AddonModDataGetEntriesOptions = {}): Promise<AddonModDataEntries> {
|
||||||
options.groupId = options.groupId || 0;
|
options.groupId = options.groupId || 0;
|
||||||
options.sort = options.sort || 0;
|
options.sort = options.sort || 0;
|
||||||
options.order || options.order || 'DESC';
|
options.order = options.order || 'DESC';
|
||||||
options.page = options.page || 0;
|
options.page = options.page || 0;
|
||||||
options.perPage = options.perPage || AddonModDataProvider.PER_PAGE;
|
options.perPage = options.perPage || AddonModDataProvider.PER_PAGE;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreGroupsProvider } from '@providers/groups';
|
import { CoreGroupsProvider } from '@providers/groups';
|
||||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreCommentsProvider } from '@core/comments/providers/comments';
|
import { CoreCommentsProvider } from '@core/comments/providers/comments';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider, CoreCourseCommonModWSOptions } from '@core/course/providers/course';
|
||||||
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
|
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
|
||||||
import { AddonModDataProvider, AddonModDataEntry } from './data';
|
import { AddonModDataProvider, AddonModDataEntry } from './data';
|
||||||
import { AddonModDataSyncProvider } from './sync';
|
import { AddonModDataSyncProvider } from './sync';
|
||||||
|
@ -100,13 +100,14 @@ export class AddonModDataPrefetchHandler extends CoreCourseActivityPrefetchHandl
|
||||||
* @param options Other options.
|
* @param options Other options.
|
||||||
* @return Promise resolved with the info fetched.
|
* @return Promise resolved with the info fetched.
|
||||||
*/
|
*/
|
||||||
protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreSitesCommonWSOptions = {})
|
protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreCourseCommonModWSOptions = {})
|
||||||
: Promise<any> {
|
: Promise<any> {
|
||||||
let database,
|
let database,
|
||||||
groups = [],
|
groups = [],
|
||||||
entries = [],
|
entries = [],
|
||||||
files = [];
|
files = [];
|
||||||
|
|
||||||
|
options.cmId = options.cmId || module.id;
|
||||||
options.siteId = options.siteId || this.sitesProvider.getCurrentSiteId();
|
options.siteId = options.siteId || this.sitesProvider.getCurrentSiteId();
|
||||||
|
|
||||||
return this.dataProvider.getDatabase(courseId, module.id, options).then((data) => {
|
return this.dataProvider.getDatabase(courseId, module.id, options).then((data) => {
|
||||||
|
|
Loading…
Reference in New Issue