• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

telefonicaid / perseo-fe / 18559502069

16 Oct 2025 11:18AM UTC coverage: 78.143% (+0.1%) from 78.011%
18559502069

push

github

web-flow
Merge pull request #817 from telefonicaid/task/upgrade_mongodb_4

upgrade dep driver mongodb to 4.17.2

797 of 1149 branches covered (69.36%)

Branch coverage included in aggregate %.

108 of 124 new or added lines in 6 files covered. (87.1%)

1 existing line in 1 file now uncovered.

2242 of 2740 relevant lines covered (81.82%)

71.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.69
/lib/models/executionsStore.js
1
/*
2
 * Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
3
 *
4
 * This file is part of perseo-fe
5
 *
6
 * perseo-fe is free software: you can redistribute it and/or
7
 * modify it under the terms of the GNU Affero General Public License as
8
 * published by the Free Software Foundation, either version 3 of the License,
9
 * or (at your option) any later version.
10
 *
11
 * perseo-fe is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 * See the GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public
17
 * License along with perseo-fe.
18
 * If not, see http://www.gnu.org/licenses/.
19
 *
20
 * For those usages not covered by the GNU Affero General Public License
21
 * please contact with::[contacto@tid.es]
22
 */
23
'use strict';
24

25
var appContext = require('../appContext'),
1✔
26
    logger = require('logops'),
1✔
27
    execCollectionName = require('../../config').collections.executions,
1✔
28
    myutils = require('../myutils');
1✔
29

30
module.exports = {
1✔
31
    LastTime: function LastTime(task, callback) {
32
        myutils.collectionExists(appContext.Db(), execCollectionName, function(exists) {
39✔
33
            if (!exists) {
39!
NEW
34
                return callback('collection ' + execCollectionName + ' does not exist');
×
35
            }
36
            var col = appContext.Db().collection(execCollectionName),
39✔
37
                service = task.event.service,
39✔
38
                subservice = task.event.subservice,
39✔
39
                ruleName = task.event.ruleName,
39✔
40
                id = task.event.id,
39✔
41
                index = task.action.index;
39✔
42

43
            var cursor = col
39✔
44
                .find(
45
                    {
46
                        name: ruleName,
47
                        subservice: subservice,
48
                        service: service,
49
                        id: id,
50
                        index: index
51
                    },
52
                    {}
53
                )
54
                .sort({ lastTime: -1 });
55
            cursor = cursor.limit(1);
39✔
56
            cursor.toArray(function(err, results) {
39✔
57
                myutils.logErrorIf(err);
39✔
58
                if (err) {
39!
59
                    return callback(err, null);
×
60
                }
61
                var data = results.length ? results[0] : null;
39✔
62
                return callback(null, (data && data.lastTime && data.lastTime.getTime()) || 0);
39✔
63
            });
64
        });
65
    },
66
    AlreadyDone: function AlreadyDone(task, callback) {
NEW
67
        myutils.collectionExists(appContext.Db(), execCollectionName, function(exists) {
×
NEW
68
            if (!exists) {
×
NEW
69
                return callback('collection ' + execCollectionName + ' does not exist');
×
70
            }
NEW
71
            var col = appContext.Db().collection(execCollectionName),
×
NEW
72
                service = task.event.service,
×
NEW
73
                subservice = task.event.subservice,
×
NEW
74
                ruleName = task.event.ruleName,
×
NEW
75
                id = task.event.id,
×
NEW
76
                index = task.action.index,
×
NEW
77
                noticeId = task.event.noticeId;
×
78

UNCOV
79
            col.findOne(
×
80
                {
81
                    name: ruleName,
82
                    subservice: subservice,
83
                    service: service,
84
                    id: id,
85
                    notice: noticeId,
86
                    index: index
87
                },
88
                function(err, data) {
89
                    myutils.logErrorIf(err);
×
90
                    if (err) {
×
91
                        return callback(err, null);
×
92
                    }
93
                    return callback(null, data);
×
94
                }
95
            );
96
        });
97
    },
98
    Update: function Update(task, callback) {
99
        myutils.collectionExists(appContext.Db(), execCollectionName, function(exists) {
8✔
100
            if (!exists) {
8!
NEW
101
                return callback('collection ' + execCollectionName + ' does not exist');
×
102
            }
103
            var col = appContext.Db().collection(execCollectionName),
8✔
104
                service = task.event.service,
8✔
105
                subservice = task.event.subservice,
8✔
106
                ruleName = task.event.ruleName,
8✔
107
                id = task.event.id,
8✔
108
                index = task.action.index,
8✔
109
                noticeId = task.event.noticeId;
8✔
110

111
            col.update(
8✔
112
                {
113
                    name: ruleName,
114
                    subservice: subservice,
115
                    service: service,
116
                    id: id,
117
                    notice: noticeId,
118
                    index: index
119
                },
120
                { $currentDate: { lastTime: true } },
121
                { upsert: true },
122
                function(err, result) {
123
                    myutils.logErrorIf(err);
8✔
124
                    logger.info('executionsStore.Update %j', result);
8✔
125
                    return callback(err, result);
8✔
126
                }
127
            );
128
        });
129
    }
130
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc