forked from Flowee/registry
Add timestamp in category jsons
And make sure that we sort newest to oldest.
This commit is contained in:
+9
-1
@@ -48,10 +48,16 @@ int Processor::run()
|
||||
for (auto i = m_categories.begin(); i != m_categories.end(); ++i) {
|
||||
MetaCategory *mc = i->second;
|
||||
QJsonArray sources;
|
||||
for (auto owner : mc->owners) {
|
||||
auto owners = std::vector<MetaBCMR*>(mc->owners.begin(), mc->owners.end());
|
||||
std::sort(owners.begin(), owners.end(), [](MetaBCMR *a, MetaBCMR *b) {
|
||||
return a->timestamp > b->timestamp;
|
||||
});
|
||||
|
||||
for (auto owner : owners) {
|
||||
QJsonObject o;
|
||||
o.insert("bcmr", owner->hash);
|
||||
o.insert("name", owner->name);
|
||||
o.insert("timestamp", owner->timestampStr);
|
||||
sources.append(o);
|
||||
}
|
||||
QJsonObject root;
|
||||
@@ -154,6 +160,8 @@ void Processor::parseBCMR(const QString &path)
|
||||
me = new MetaBCMR();
|
||||
me->origFilename = path;
|
||||
me->name = revision["name"].toString();
|
||||
me->timestampStr = revisionDates.back();
|
||||
me->timestamp = QDateTime::fromString(me->timestampStr, Qt::ISODate);
|
||||
// calc hash
|
||||
CSHA256 hasher;
|
||||
hasher.write(data.constData(), data.size());
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
#include <QFile>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <QDateTime>
|
||||
|
||||
class Processor
|
||||
{
|
||||
@@ -23,8 +24,9 @@ private:
|
||||
QString hash;
|
||||
QString origFilename;
|
||||
QString name;
|
||||
QString timestampStr;
|
||||
QDateTime timestamp;
|
||||
std::vector<struct MetaCategory*> tokens;
|
||||
|
||||
};
|
||||
|
||||
struct MetaCategory {
|
||||
|
||||
Reference in New Issue
Block a user